From ac00c36910af804698a0664e3056ce4d327916db Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 7 Sep 2015 01:07:44 +0000 Subject: [PATCH] dropped the encname column from the file table updated database schema files --- codepot/README | 1 + codepot/etc/codepot.mysql | 3 --- codepot/etc/codepot.oracle | 32 ++++++++++++++++++------ codepot/etc/codepot.pgsql | 21 +++++++++++++--- codepot/src/codepot/models/filemodel.php | 1 - 5 files changed, 42 insertions(+), 16 deletions(-) diff --git a/codepot/README b/codepot/README index 5784a4ac..0d45a7be 100644 --- a/codepot/README +++ b/codepot/README @@ -20,6 +20,7 @@ UPGRADING FROM 0.2.0 mysql> INSERT INTO file_list (projectid, name, filename, encname, md5sum, description) SELECT projectid, name, name, encname, md5sum, summary FROM file WHERE md5sum != ''; mysql> ALTER TABLE file DROP COLUMN summary; mysql> ALTER TABLE file DROP COLUMN md5sum; + mysql> ALTER TABLE file DROP COLUMN encname; INSTALLATION ON CENTOS diff --git a/codepot/etc/codepot.mysql b/codepot/etc/codepot.mysql index 55201ef0..0135e410 100644 --- a/codepot/etc/codepot.mysql +++ b/codepot/etc/codepot.mysql @@ -160,10 +160,7 @@ CREATE TABLE issue_change_attachment ( CREATE TABLE file ( projectid VARCHAR(32) NOT NULL, name VARCHAR(255) NOT NULL, - encname VARCHAR(255) NOT NULL, tag VARCHAR(54) NOT NULL, - summary VARCHAR(255) NOT NULL, - md5sum CHAR(32) NOT NULL, description TEXT NOT NULL, createdon DATETIME NOT NULL, diff --git a/codepot/etc/codepot.oracle b/codepot/etc/codepot.oracle index ed3760fe..3534e115 100644 --- a/codepot/etc/codepot.oracle +++ b/codepot/etc/codepot.oracle @@ -145,24 +145,34 @@ CREATE TABLE "cpot_issue_change_attachment" ( ); CREATE TABLE "cpot_file" ( - "projectid" VARCHAR(32) NOT NULL, - "name" VARCHAR(255) NOT NULL, - "encname" VARCHAR(255) NOT NULL, - "tag" VARCHAR(54) NOT NULL, - "summary" VARCHAR(255) NOT NULL, - "md5sum" CHAR(32) NOT NULL, - "description" CLOB NOT NULL, + "projectid" VARCHAR(32) NOT NULL, + "name" VARCHAR(255) NOT NULL, + "tag" VARCHAR(54) NOT NULL, + "description" CLOB NOT NULL, "createdon" TIMESTAMP NOT NULL, "updatedon" TIMESTAMP NOT NULL, "createdby" VARCHAR(32) NOT NULL, "updatedby" VARCHAR(32) NOT NULL, UNIQUE ("projectid", "name"), - UNIQUE ("encname"), CONSTRAINT file_projectid FOREIGN KEY ("projectid") REFERENCES "cpot_project"("id") ); CREATE INDEX cpot_file_index_1 ON "cpot_file"("projectid", "tag", "name"); +CREATE TABLE "cpot_file_list" ( + "projectid" VARCHAR(32) NOT NULL, + "name" VARCHAR(255) NOT NULL, + "filename" VARCHAR(255) NOT NULL, + "encname" VARCHAR(255) NOT NULL, + "md5sum" CHAR(32) NOT NULL, + "description" CLOB NOT NULL, + UNIQUE ("projectid", "filename"), + UNIQUE ("encname"), + CONSTRAINT file_list_projectid FOREIGN KEY ("projectid","name") REFERENCES "cpot_file"("projectid","name") +); + +CREATE INDEX cpot_file_list_index_1 ON "cpot_file_list"("projectid", "name"); + CREATE TABLE "cpot_code_review" ( "projectid" VARCHAR(32) NOT NULL, "rev" NUMBER(20,0) NOT NULL, @@ -242,3 +252,9 @@ BEGIN UPDATE "cpot_issue_change_attachment" SET "issuesno" = :new."sno" WHERE "projectid" = :old."projectid" AND "issueid" = :old."id" AND "issuesno" = :old."sno"; END; / + +CREATE OR REPLACE TRIGGER cpot_upon_file_name_update AFTER UPDATE OF "name" ON "cpot_file" FOR EACH ROW +BEGIN + UPDATE "cpot_file_list" SET "name" = :new."name" WHERE "projectid" = :old."projectid" AND "name" = :old."name"; +END; +/ diff --git a/codepot/etc/codepot.pgsql b/codepot/etc/codepot.pgsql index 652de29f..e501974f 100644 --- a/codepot/etc/codepot.pgsql +++ b/codepot/etc/codepot.pgsql @@ -179,10 +179,7 @@ CREATE TABLE issue_change_attachment ( CREATE TABLE file ( projectid VARCHAR(32) NOT NULL, name VARCHAR(255) NOT NULL, - encname VARCHAR(255) NOT NULL, tag VARCHAR(54) NOT NULL, - summary VARCHAR(255) NOT NULL, - md5sum CHAR(32) NOT NULL, description TEXT NOT NULL, createdon TIMESTAMP NOT NULL, @@ -191,7 +188,6 @@ CREATE TABLE file ( updatedby VARCHAR(32) NOT NULL, UNIQUE (projectid, name), - UNIQUE (encname), CONSTRAINT file_projectid FOREIGN KEY (projectid) REFERENCES project(id) ON DELETE RESTRICT ON UPDATE CASCADE @@ -199,6 +195,23 @@ CREATE TABLE file ( CREATE INDEX file_index_1 ON file(projectid, tag, name); +CREATE TABLE file_list ( + projectid VARCHAR(32) NOT NULL, + name VARCHAR(255) NOT NULL, + filename VARCHAR(255) NOT NULL, + encname VARCHAR(255) NOT NULL, + md5sum CHAR(32) NOT NULL, + description VARCHAR(255) NOT NULL, + + UNIQUE (projectid, filename), + UNIQUE (encname), + + CONSTRAINT file_list_projectid FOREIGN KEY (projectid,name) REFERENCES file(projectid,name) + ON DELETE RESTRICT ON UPDATE CASCADE +); + +CREATE INDEX file_list_index_1 ON file(projectid, name); + CREATE TABLE code_review ( projectid VARCHAR(32) NOT NULL, rev BIGINT NOT NULL, diff --git a/codepot/src/codepot/models/filemodel.php b/codepot/src/codepot/models/filemodel.php index 79a4e650..71270e1e 100644 --- a/codepot/src/codepot/models/filemodel.php +++ b/codepot/src/codepot/models/filemodel.php @@ -251,7 +251,6 @@ class FileModel extends Model $this->db->set ('projectid', $projectid); $this->db->set ('name', $name); - $this->db->set ('encname', ''); $this->db->set ('tag', $tag); $this->db->set ('description', $description); $this->db->set ('createdon', date('Y-m-d H:i:s'));