Bladeren bron

added DB schema

master
root 5 jaren geleden
bovenliggende
commit
85c6dc7237
3 gewijzigde bestanden met toevoegingen van 103 en 4 verwijderingen
  1. 8
    3
      cgi/autodoc.fcgi
  2. 94
    0
      etc/mysql.schema
  3. 1
    1
      www/js/autodoc.js

+ 8
- 3
cgi/autodoc.fcgi Bestand weergeven

@@ -61,6 +61,8 @@ while($request->Accept() >= 0) {

my($code, $hdr, $type, $data) = process_query($method, $path, $qs, $post, $user);

print STDERR Dumper("code",$code,"hdr", $hdr, "type", $type, "data", $data);

$hdr = [ ] if !defined $hdr;

if ( defined $type ) {
@@ -84,8 +86,9 @@ sub send_response {
}

sub fatal_api_error {
my($code,$type,$body)=api_error(@_);
send_response($code, undef, $type, $body);
my($code,$hdr,$type,$body)=api_error(@_);
print STDERR "AUTODOC_FATAL: $body\r\n";
send_response($code, $hdr, $type, $body);
exit;
}

@@ -163,7 +166,7 @@ sub db_get_document_object {
tags => [ @tags ],
};

return (200, "application/json", $out);
return (200, undef, "application/json", $out);
}

return (404, undef, "application/json", "");
@@ -493,6 +496,8 @@ sub sqlquery {
my $query = shift;
my @args = @_;

print STDERR "$query\n";

my $sth = $dbh->prepare($query) || fatal_api_error(500,"Failed to execute SQL query");
$sth->execute(@args) || fatal_api_error(500,"Failed to execute SQL query");
return $sth;

+ 94
- 0
etc/mysql.schema Bestand weergeven

@@ -0,0 +1,94 @@
DROP TABLE IF EXISTS `documents`;
CREATE TABLE `documents` (
`id` char(36) NOT NULL,
`owner` varchar(45) DEFAULT NULL,
`name` varchar(45) DEFAULT NULL,
`created` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`status` enum('nodata','inprogress','deleted','ok') NOT NULL DEFAULT 'nodata',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `documents_page`;
CREATE TABLE `documents_page` (
`documentId` char(36) NOT NULL,
`pageId` char(36) NOT NULL,
PRIMARY KEY (`documentId`,`pageId`),
KEY `fk_docpage_pageid_idx` (`pageId`),
CONSTRAINT `fk_docpage_docid` FOREIGN KEY (`documentId`) REFERENCES `documents` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT `fk_docpage_pageid` FOREIGN KEY (`pageId`) REFERENCES `pages` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `documents_tags`;
CREATE TABLE `documents_tags` (
`documentId` char(36) NOT NULL,
`tagId` char(36) NOT NULL,
PRIMARY KEY (`documentId`,`tagId`),
KEY `fk_tags_id_idx` (`tagId`),
CONSTRAINT `fk_doctags_docid` FOREIGN KEY (`documentId`) REFERENCES `documents` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT `fk_doctags_tagid` FOREIGN KEY (`tagId`) REFERENCES `tags` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `lang`;
CREATE TABLE `lang` (
`id` char(36) NOT NULL,
`short` char(2) DEFAULT NULL,
`name` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `short_UNIQUE` (`short`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `pages`;
CREATE TABLE `pages` (
`id` char(36) NOT NULL,
`owner` varchar(45) DEFAULT NULL,
`documentId` int(11) unsigned NOT NULL,
`name` varchar(45) DEFAULT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`status` enum('nodata','inprogress','deleted','ok') DEFAULT 'nodata',
`contenttype` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `pages_words`;
CREATE TABLE `pages_words` (
`pageId` char(36) NOT NULL,
`wordId` char(36) NOT NULL DEFAULT 'en',
PRIMARY KEY (`pageId`,`wordId`),
KEY `fk_pagword_wordid_idx` (`wordId`),
CONSTRAINT `fk_pagword_pageid` FOREIGN KEY (`pageId`) REFERENCES `pages` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT `fk_pagword_wordid` FOREIGN KEY (`wordId`) REFERENCES `words` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `tags`;
CREATE TABLE `tags` (
`id` char(36) NOT NULL,
`tag` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `tag_UNIQUE` (`tag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`username` varchar(255) NOT NULL,
`passwd` varchar(255) DEFAULT NULL,
`groups` varchar(255) DEFAULT NULL,
PRIMARY KEY (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `words`;
CREATE TABLE `words` (
`id` char(36) NOT NULL,
`word` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `word_UNIQUE` (`word`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `words_lang`;
CREATE TABLE `words_lang` (
`wordId` char(36) NOT NULL,
`langId` char(36) NOT NULL,
PRIMARY KEY (`wordId`,`langId`),
KEY `fk_worlan_langid_idx` (`langId`),
CONSTRAINT `fk_worlan_langid` FOREIGN KEY (`langId`) REFERENCES `lang` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT `fk_worlan_wordid` FOREIGN KEY (`wordId`) REFERENCES `words` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

+ 1
- 1
www/js/autodoc.js Bestand weergeven

@@ -355,4 +355,4 @@ function upload_status() {
else {
setTimeout(function () { upload_status(); }, 100);
}
}
}

Laden…
Annuleren
Opslaan