updated database schema

This commit is contained in:
hyung-hwan 2016-01-23 06:15:59 +00:00
parent 25e7e9e969
commit 8d925fb2b5
3 changed files with 42 additions and 5 deletions

View File

@ -26,6 +26,7 @@ UPGRADING FROM 0.2.0
mysql> create the issue_file_list table according to the definition found in codepot.mysql
mysql> ALTER TABLE issue_change ADD COLUMN(createdon datetime not null, createdby varchar(32) not null);
mysql> UPDATE issue_change SET createdby=updatedby, createdon=updatedon;
mysql> create the issue_coderev table according to the definition found in codepot.mysql
INSTALLATION ON CENTOS

View File

@ -155,6 +155,19 @@ CREATE TABLE "cpot_issue_change_file_list" (
CONSTRAINT issue_change_file_list_c2 FOREIGN KEY ("projectid","issueid","issuesno") REFERENCES "cpot_issue_change"("projectid","id","sno")
);
CREATE TABLE "cpot_issue_coderev" (
"projectid" VARCHAR(32) NOT NULL,
"issueid" NUMBER(20,0) NOT NULL,
"codeproid" VARCHAR(32) NOT NULL,
"coderev" VARCHAR(64) NOT NULL,
UNIQUE ("projectid", "issueid", "codeproid", "coderev"),
CONSTRAINT issue_coderev_projectid FOREIGN KEY ("projectid") REFERENCES "project"("id"),
CONSTRAINT issue_coderev_codeproid FOREIGN KEY ("codeproid") REFERENCES "project"("id")
);
CREATE INDEX issue_coderev_index_1 ON "issue_coderev"("codeproid", "coderev");
CREATE INDEX issue_coderev_index_2 ON "issue_coderev"("projectid", "issueid");
CREATE TABLE "cpot_file" (
"projectid" VARCHAR(32) NOT NULL,
"name" VARCHAR(255) NOT NULL,
@ -192,7 +205,7 @@ CREATE TABLE "cpot_code_review" (
"projectid" VARCHAR(32) NOT NULL,
"rev" NUMBER(20,0) NOT NULL,
"sno" NUMBER(20,0) NOT NULL,
"comment" CLOB NOT NULL,
"comment" CLOB NOT NULL,
"createdon" TIMESTAMP NOT NULL,
"createdby" VARCHAR(32) NOT NULL,
"updatedon" TIMESTAMP NOT NULL,
@ -240,9 +253,11 @@ BEGIN
UPDATE "cpot_wiki" SET "projectid" = :new."id" WHERE "projectid" = :old."id";
UPDATE "cpot_wiki_attachment" SET "projectid" = :new."id" WHERE "projectid" = :old."id";
UPDATE "cpot_issue" SET "projectid" = :new."id" WHERE "projectid"= :old."id";
UPDATE "cpot_issue_attachment" SET "projectid" = :new."id" WHERE "projectid" = :old."id";
UPDATE "cpot_issue_file_list" SET "projectid" = :new."id" WHERE "projectid" = :old."id";
UPDATE "cpot_issue_change" SET "projectid" = :new."id" WHERE "projectid" = :old."id";
UPDATE "cpot_issue_change_attachment" SET "projectid" = :new."id" WHERE "projectid" = :old."id";
UPDATE "cpot_issue_change_file_list" SET "projectid" = :new."id" WHERE "projectid" = :old."id";
UPDATE "cpot_issue_coderev" SET "projectid" = :new."id" WHERE "projectid" = :old."id";
UPDATE "cpot_issue_coderev" SET "codeproid" = :new."id" WHERE "codeproid" = :old."id";
UPDATE "cpot_file" SET "projectid" = :new."id" WHERE "projectid" = :old."id";
UPDATE "cpot_code_review" SET "projectid" = :new."id" WHERE "projectid" = :old."id";
END;
@ -258,13 +273,14 @@ CREATE OR REPLACE TRIGGER cpot_upon_issue_id_update AFTER UPDATE OF "id" ON "cpo
BEGIN
UPDATE "cpot_issue_file_list" SET "issueid" = :new."id" WHERE "projectid" = :old."projectid" AND "issueid" = :old."id";
UPDATE "cpot_issue_change" SET "id" = :new."id" WHERE "projectid" = :old."projectid" AND "id" = :old."id";
UPDATE "cpot_issue_change_attachment" SET "issueid" = :new."id" WHERE "projectid" = :old."projectid" AND "issueid" = :old."id";
UPDATE "cpot_issue_change_file_list" SET "issueid" = :new."id" WHERE "projectid" = :old."projectid" AND "issueid" = :old."id";
UPDATE "cpot_issue_coderev" SET "issueid" = :new."id" WHERE WHERE "projectid" = :old."projectid" AND "issueid" = :old."id";
END;
/
CREATE OR REPLACE TRIGGER cpot_upon_issue_chsno_update AFTER UPDATE OF "id" ON "cpot_issue_change" FOR EACH ROW
BEGIN
UPDATE "cpot_issue_change_attachment" SET "issuesno" = :new."sno" WHERE "projectid" = :old."projectid" AND "issueid" = :old."id" AND "issuesno" = :old."sno";
UPDATE "cpot_issue_change_file_list" SET "issuesno" = :new."sno" WHERE "projectid" = :old."projectid" AND "issueid" = :old."id" AND "issuesno" = :old."sno";
END;
/

View File

@ -187,6 +187,26 @@ CREATE TABLE issue_change_file_list (
ON DELETE RESTRICT ON UPDATE CASCADE
);
CREATE TABLE issue_coderev (
projectid VARCHAR(32) NOT NULL,
issueid BIGINT NOT NULL,
codeproid VARCHAR(32) NOT NULL,
coderev VARCHAR(64) NOT NULL,
UNIQUE (projectid, issueid, codeproid, coderev),
CONSTRAINT issue_coderev_projectid FOREIGN KEY (projectid) REFERENCES project(id)
ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT issue_coderev_codeproid FOREIGN KEY (codeproid) REFERENCES project(id)
ON DELETE RESTRICT ON UPDATE CASCADE
);
CREATE INDEX issue_coderev_index_1 ON issue_coderev(codeproid, coderev);
CREATE INDEX issue_coderev_index_2 ON issue_coderev(projectid, issueid);
CREATE TABLE file (
projectid VARCHAR(32) NOT NULL,
name VARCHAR(255) NOT NULL,