mirror of
https://git.code.sf.net/p/seeddms/code
synced 2024-11-26 15:32:13 +00:00
adding sql statements for updating to new workflow layout
This commit is contained in:
parent
5882fc10a9
commit
54ce5a7e16
|
@ -6,6 +6,30 @@ ALTER TABLE "tblUsers" ADD COLUMN "secret" varchar(50) default NULL;
|
|||
|
||||
ALTER TABLE "tblWorkflows" ADD COLUMN "layoutdata" text default NULL;
|
||||
|
||||
ALTER TABLE "tblWorkflowDocumentContent" ADD COLUMN "id" SERIAL UNIQUE;
|
||||
|
||||
ALTER TABLE "tblWorkflowLog" ADD COLUMN "workflowdocumentcontent" INTEGER NOT NULL DEFAULT '0';
|
||||
|
||||
UPDATE "tblWorkflowLog" SET "workflowdocumentcontent" = "tblWorkflowDocumentContent"."id" FROM "tblWorkflowDocumentContent" WHERE "tblWorkflowLog"."document" = "tblWorkflowDocumentContent"."document" AND "tblWorkflowLog"."version" = "tblWorkflowDocumentContent"."version" AND "tblWorkflowLog"."workflow" = "tblWorkflowDocumentContent"."workflow";
|
||||
|
||||
INSERT INTO "tblWorkflowDocumentContent" ("parentworkflow", "workflow", "document", "version", "state", "date") SELECT 0 AS "parentworkflow", "workflow", "document", "version", NULL AS "state", max("date") AS "date" FROM "tblWorkflowLog" WHERE "workflowdocumentcontent" = 0 GROUP BY "workflow", "document", "version";
|
||||
|
||||
UPDATE "tblWorkflowLog" SET "workflowdocumentcontent" = "tblWorkflowDocumentContent"."id" FROM "tblWorkflowDocumentContent" WHERE "tblWorkflowLog"."document" = "tblWorkflowDocumentContent"."document" AND "tblWorkflowLog"."version" = "tblWorkflowDocumentContent"."version" AND "tblWorkflowLog"."workflow" = "tblWorkflowDocumentContent"."workflow";
|
||||
|
||||
ALTER TABLE "tblWorkflowLog" ADD CONSTRAINT "tblWorkflowLog_workflowdocumentcontent" FOREIGN KEY ("workflowdocumentcontent") REFERENCES "tblWorkflowDocumentContent" ("id") ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE "tblWorkflowDocumentContent" ADD COLUMN "parent" INTEGER DEFAULT NULL;
|
||||
|
||||
ALTER TABLE "tblWorkflowDocumentContent" ADD CONSTRAINT "tblWorkflowDocumentContent_parent" FOREIGN KEY ("parent") REFERENCES "tblWorkflowDocumentContent" ("id") ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE "tblWorkflowDocumentContent" DROP COLUMN "parentworkflow";
|
||||
|
||||
ALTER TABLE "tblWorkflowLog" DROP COLUMN "document";
|
||||
|
||||
ALTER TABLE "tblWorkflowLog" DROP COLUMN "version";
|
||||
|
||||
ALTER TABLE "tblWorkflowLog" DROP COLUMN "workflow";
|
||||
|
||||
CREATE TABLE "tblUserSubstitutes" (
|
||||
"id" SERIAL UNIQUE,
|
||||
"user" INTEGER default null,
|
||||
|
|
|
@ -6,6 +6,39 @@ ALTER TABLE `tblUsers` ADD COLUMN `secret` varchar(50) default NULL;
|
|||
|
||||
ALTER TABLE `tblWorkflows` ADD COLUMN `layoutdata` text default NULL;
|
||||
|
||||
CREATE TABLE `new_tblWorkflowDocumentContent` (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`parent` INTEGER DEFAULT NULL REFERENCES `new_tblWorkflowDocumentContent` (`id`) ON DELETE CASCADE,
|
||||
`workflow` INTEGER DEFAULT NULL REFERENCES `tblWorkflows` (`id`) ON DELETE CASCADE,
|
||||
`document` INTEGER DEFAULT NULL REFERENCES `tblDocuments` (`id`) ON DELETE CASCADE,
|
||||
`version` INTEGER DEFAULT NULL,
|
||||
`state` INTEGER DEFAULT NULL REFERENCES `tblWorkflowStates` (`id`) ON DELETE CASCADE,
|
||||
`date` datetime NOT NULL
|
||||
) ;
|
||||
|
||||
INSERT INTO `new_tblWorkflowDocumentContent` (`parent`, `workflow`, `document`, `version`, `state`, `date`) SELECT NULL as `parent`, `workflow`, `document`, `version`, `state`, `date` FROM `tblWorkflowDocumentContent`;
|
||||
|
||||
INSERT INTO `new_tblWorkflowDocumentContent` (`parent`, `workflow`, `document`, `version`, `state`, `date`) SELECT NULL, `a`.`workflow`, `a`.`document`, `a`.`version`, NULL AS `state`, max(`a`.`date`) FROM `tblWorkflowLog` `a` LEFT JOIN `tblWorkflowDocumentContent` `b` ON `a`.`document`=`b`.`document` AND `a`.`version`=`b`.`version` AND `a`.`workflow`=`b`.`workflow` WHERE `b`.`document` IS NULL GROUP BY `a`.`document`, `a`.`version`, `a`.`workflow`;
|
||||
|
||||
CREATE TABLE `new_tblWorkflowLog` (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`workflowdocumentcontent` INTEGER DEFAULT NULL REFERENCES `new_tblWorkflowDocumentContent` (`id`) ON DELETE CASCADE,
|
||||
`userid` INTEGER default NULL REFERENCES `tblUsers` (`id`) ON DELETE CASCADE,
|
||||
`transition` INTEGER default NULL REFERENCES `tblWorkflowTransitions` (`id`) ON DELETE CASCADE,
|
||||
`date` datetime NOT NULL,
|
||||
`comment` text
|
||||
) ;
|
||||
|
||||
INSERT INTO `new_tblWorkflowLog` (`id`, `workflowdocumentcontent`, `userid`, `transition`, `date`, `comment`) SELECT `a`.`id`, `b`.`id`, `a`.`userid`, `a`.`transition`, `a`.`date`, `a`.`comment` FROM `tblWorkflowLog` `a` LEFT JOIN `new_tblWorkflowDocumentContent` `b` ON `a`.`document`=`b`.`document` AND `a`.`version`=`b`.`version` AND `a`.`workflow`=`b`.`workflow` WHERE `b`.`document` IS NOT NULL;
|
||||
|
||||
DROP TABLE `tblWorkflowLog`;
|
||||
|
||||
ALTER TABLE `new_tblWorkflowLog` RENAME TO `tblWorkflowLog`;
|
||||
|
||||
DROP TABLE `tblWorkflowDocumentContent`;
|
||||
|
||||
ALTER TABLE `new_tblWorkflowDocumentContent` RENAME TO `tblWorkflowDocumentContent`;
|
||||
|
||||
CREATE TABLE `tblUserSubstitutes` (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`user` INTEGER NOT NULL default '0' REFERENCES `tblUsers` (`id`) ON DELETE CASCADE,
|
||||
|
@ -121,6 +154,8 @@ ALTER TABLE tblUsers RENAME TO old_tblUsers;
|
|||
|
||||
ALTER TABLE new_tblUsers RENAME TO tblUsers;
|
||||
|
||||
DROP TABLE old_tblUsers;
|
||||
|
||||
CREATE TABLE `tblAros` (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`parent` INTEGER,
|
||||
|
|
|
@ -12,7 +12,7 @@ ALTER TABLE `tblWorkflowLog` ADD COLUMN `workflowdocumentcontent` int(11) NOT NU
|
|||
|
||||
UPDATE `tblWorkflowLog` a, `tblWorkflowDocumentContent` b SET a.`workflowdocumentcontent` = b.`id` WHERE a.`document` = b.`document` AND a.`version` = b.`version` AND a.`workflow` = b.`workflow`;
|
||||
|
||||
INSERT INTO `tblWorkflowDocumentContent` (`parentworkflow`, `workflow`, `document`, `version`, `state`, `date`) SELECT 0 as `parentworkflow`, `workflow`, `document`, `version`, NULL as `state`, max(`date`) as `date` FROM `tblWorkflowLog` WHERE `workflowdocumentcontent` = 0 GROUP BY `workflow`, `document`, `version`;
|
||||
INSERT INTO `tblWorkflowDocumentContent` (`parentworkflow`, `workflow`, `document`, `version`, `state`, `date`) SELECT 0 AS `parentworkflow`, `workflow`, `document`, `version`, NULL AS `state`, max(`date`) AS `date` FROM `tblWorkflowLog` WHERE `workflowdocumentcontent` = 0 GROUP BY `workflow`, `document`, `version`;
|
||||
|
||||
UPDATE `tblWorkflowLog` a, `tblWorkflowDocumentContent` b SET a.`workflowdocumentcontent` = b.`id` WHERE a.`document` = b.`document` AND a.`version` = b.`version` AND a.`workflow` = b.`workflow`;
|
||||
|
||||
|
@ -24,6 +24,12 @@ ALTER TABLE `tblWorkflowDocumentContent` ADD CONSTRAINT `tblWorkflowDocumentCont
|
|||
|
||||
ALTER TABLE `tblWorkflowDocumentContent` DROP COLUMN `parentworkflow`;
|
||||
|
||||
ALTER TABLE `tblWorkflowLog` DROP COLUMN `document`;
|
||||
|
||||
ALTER TABLE `tblWorkflowLog` DROP COLUMN `version`;
|
||||
|
||||
ALTER TABLE `tblWorkflowLog` DROP COLUMN `workflow`;
|
||||
|
||||
CREATE TABLE `tblUserSubstitutes` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`user` int(11) DEFAULT null,
|
||||
|
|
Loading…
Reference in New Issue
Block a user