add sql scripts

This commit is contained in:
CITE\amentis 2024-10-02 13:36:49 +03:00
parent e0a7d83712
commit 6a8c5ac947
4 changed files with 83 additions and 0 deletions

View File

@ -15,6 +15,7 @@ BEGIN
internal_status smallint,
tenant uuid,
definition xml,
action character varying(250) COLLATE pg_catalog."default",
CONSTRAINT "PlanStatus_pkey" PRIMARY KEY (id),
CONSTRAINT "PlanStatus_tenant_fkey" FOREIGN KEY (tenant)
REFERENCES public."Tenant" (id) MATCH SIMPLE

View File

@ -15,6 +15,7 @@ BEGIN
internal_status smallint,
definition xml,
tenant uuid,
action character varying(250) COLLATE pg_catalog."default",
CONSTRAINT "DescriptionStatus_pkey" PRIMARY KEY (id),
CONSTRAINT "DescriptionStatus_tenant_fkey" FOREIGN KEY (tenant)
REFERENCES public."Tenant" (id) MATCH SIMPLE

View File

@ -0,0 +1,23 @@
DO $$DECLARE
this_version CONSTANT varchar := '00.01.076';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
INSERT INTO public."PlanStatus" (id, name, description, created_at, updated_at, is_active, internal_status, tenant, definition, action) VALUES ('cb3ced76-9807-4829-82da-75777de1bc78', 'Draft', NULL, '2024-09-17 07:37:24.288404', '2024-09-20 10:34:51.23021', 1, 0, NULL, '<?xml version="1.0" standalone="yes"?><definition><authorization><edit><roles/><plan_roles><plan_roles>Owner</plan_roles><plan_roles>Viewer</plan_roles><plan_roles>DescriptionContributor</plan_roles><plan_roles>Reviewer</plan_roles></plan_roles><allowAuthenticated>false</allowAuthenticated><allowAnonymous>false</allowAnonymous></edit></authorization><availableActions><action>Export</action></availableActions></definition>', NULL);
INSERT INTO public."PlanStatus" (id, name, description, created_at, updated_at, is_active, internal_status, tenant, definition, action) VALUES ('f1a3da63-0bff-438f-8b46-1a81ca176115', 'Finalized', NULL, '2024-09-16 14:16:56.685177', '2024-09-23 12:58:56.093437', 1, 1, NULL, '<?xml version="1.0" standalone="yes"?><definition><authorization><edit><roles/><plan_roles><plan_roles>Owner</plan_roles></plan_roles><allowAuthenticated>false</allowAuthenticated><allowAnonymous>false</allowAnonymous></edit></authorization><availableActions><action>Deposit</action><action>Export</action></availableActions></definition>', 'Finalize');
INSERT INTO public."PlanStatus" (id, name, description, created_at, updated_at, is_active, internal_status, tenant, definition, action) VALUES ('61fd91f5-c63a-45bc-aa7a-e1f00fbd8545', 'Validated', NULL, '2024-09-17 07:36:38.386887', '2024-09-23 12:28:31.57448', 1, NULL, NULL, '<?xml version="1.0" standalone="yes"?><definition><authorization><edit><roles/><plan_roles><plan_roles>Reviewer</plan_roles></plan_roles><allowAuthenticated>false</allowAuthenticated><allowAnonymous>false</allowAnonymous></edit></authorization><availableActions><action>Export</action></availableActions></definition>', 'Validate');
INSERT INTO public."PlanStatus" (id, name, description, created_at, updated_at, is_active, internal_status, tenant, definition, action) VALUES ('313cce74-f44b-4a72-9cd8-a9c75fe03a7e', 'Under Review', NULL, '2024-09-17 07:36:58.677058', '2024-09-23 12:28:48.897145', 1, NULL, NULL, '<?xml version="1.0" standalone="yes"?><definition><authorization><edit><roles/><plan_roles><plan_roles>Owner</plan_roles></plan_roles><allowAuthenticated>false</allowAuthenticated><allowAnonymous>false</allowAnonymous></edit></authorization><availableActions><action>Export</action></availableActions></definition>', 'Review');
INSERT INTO public."DescriptionStatus" (id, name, description, created_at, updated_at, is_active, internal_status, definition, tenant, action) VALUES ('978e6ff6-b5e9-4cee-86cb-bc7401ec4059', 'Draft', NULL, '2024-09-16 12:46:20.459486', '2024-09-20 12:21:00.641011', 1, 0, '<?xml version="1.0" standalone="yes"?><definition><authorization><edit><roles/><plan_roles><plan_roles>Owner</plan_roles><plan_roles>Viewer</plan_roles><plan_roles>DescriptionContributor</plan_roles><plan_roles>Reviewer</plan_roles></plan_roles><allowAuthenticated>false</allowAuthenticated><allowAnonymous>false</allowAnonymous></edit></authorization><availableActions><action>Export</action></availableActions></definition>', NULL, NULL);
INSERT INTO public."DescriptionStatus" (id, name, description, created_at, updated_at, is_active, internal_status, definition, tenant, action) VALUES ('60f5e529-7ed3-4be1-8754-ac8c7443f246', 'Canceled', NULL, '2024-09-17 15:37:42.256424', '2024-09-25 07:47:24.839357', 1, 2, '<?xml version="1.0" standalone="yes"?><definition><authorization><edit><roles/><plan_roles><plan_roles>Owner</plan_roles></plan_roles><allowAuthenticated>false</allowAuthenticated><allowAnonymous>false</allowAnonymous></edit></authorization><availableActions><action>Export</action></availableActions></definition>', NULL, 'Cancel');
INSERT INTO public."DescriptionStatus" (id, name, description, created_at, updated_at, is_active, internal_status, definition, tenant, action) VALUES ('c266e2ee-9ae9-4a2f-9b4b-bc6fb1dd54aa', 'Finalized', NULL, '2024-09-17 07:38:15.846399', '2024-09-23 12:55:39.702483', 1, 1, '<?xml version="1.0" standalone="yes"?><definition><authorization><edit><roles/><plan_roles><plan_roles>Owner</plan_roles></plan_roles><allowAuthenticated>false</allowAuthenticated><allowAnonymous>false</allowAnonymous></edit></authorization><availableActions><action>Export</action></availableActions></definition>', NULL, 'Finalize');
INSERT INTO public."PlanWorkflow" (id, name, description, created_at, updated_at, is_active, definition, tenant) VALUES ('44df0e24-7879-48cc-bbe0-cd8a2b618855', 'default', NULL, '2024-09-18 11:39:30.5974', '2024-09-18 11:39:30.611945', 1, '<?xml version="1.0" standalone="yes"?><definition><startingStatusId>cb3ced76-9807-4829-82da-75777de1bc78</startingStatusId><statusTransitions><fromStatusId>cb3ced76-9807-4829-82da-75777de1bc78</fromStatusId><toStatusId>313cce74-f44b-4a72-9cd8-a9c75fe03a7e</toStatusId></statusTransitions><statusTransitions><fromStatusId>313cce74-f44b-4a72-9cd8-a9c75fe03a7e</fromStatusId><toStatusId>61fd91f5-c63a-45bc-aa7a-e1f00fbd8545</toStatusId></statusTransitions><statusTransitions><fromStatusId>61fd91f5-c63a-45bc-aa7a-e1f00fbd8545</fromStatusId><toStatusId>f1a3da63-0bff-438f-8b46-1a81ca176115</toStatusId></statusTransitions><statusTransitions><fromStatusId>f1a3da63-0bff-438f-8b46-1a81ca176115</fromStatusId><toStatusId>cfa5cff0-0cbf-4ae7-87b7-263343991f35</toStatusId></statusTransitions><statusTransitions><fromStatusId>cb3ced76-9807-4829-82da-75777de1bc78</fromStatusId><toStatusId>f1a3da63-0bff-438f-8b46-1a81ca176115</toStatusId></statusTransitions><statusTransitions><fromStatusId>f1a3da63-0bff-438f-8b46-1a81ca176115</fromStatusId><toStatusId>cb3ced76-9807-4829-82da-75777de1bc78</toStatusId></statusTransitions></definition>', NULL);
INSERT INTO public."DescriptionWorkflow" (id, name, description, created_at, updated_at, is_active, definition, tenant) VALUES ('8651af83-8b24-4776-ae45-329031db9f5e', 'default', NULL, '2024-09-17 07:39:00.221933', '2024-09-18 10:51:14.478419', 1, '<?xml version="1.0" standalone="yes"?><definition><startingStatusId>978e6ff6-b5e9-4cee-86cb-bc7401ec4059</startingStatusId><statusTransitions><fromStatusId>978e6ff6-b5e9-4cee-86cb-bc7401ec4059</fromStatusId><toStatusId>c266e2ee-9ae9-4a2f-9b4b-bc6fb1dd54aa</toStatusId></statusTransitions><statusTransitions><fromStatusId>c266e2ee-9ae9-4a2f-9b4b-bc6fb1dd54aa</fromStatusId><toStatusId>978e6ff6-b5e9-4cee-86cb-bc7401ec4059</toStatusId></statusTransitions></definition>', NULL);
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.076', '2024-09-18 12:00:00.000000+02', now(), 'Insert values for Plan, Description Status and Workflow.');
END$$;

View File

@ -0,0 +1,58 @@
DO $$DECLARE
this_version CONSTANT varchar := '00.01.077';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
ALTER TABLE public."Plan"
ADD COLUMN status_id uuid;
ALTER TABLE public."Plan"
ADD CONSTRAINT "Plan_status_fkey" FOREIGN KEY (status_id)
REFERENCES public."PlanStatus" (id)
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID;
UPDATE public."Plan" SET
status_id = 'cb3ced76-9807-4829-82da-75777de1bc78'
WHERE status = 0;
UPDATE public."Plan" SET
status_id = 'f1a3da63-0bff-438f-8b46-1a81ca176115'
WHERE status = 1;
ALTER TABLE IF EXISTS public."Plan" DROP COLUMN IF EXISTS status;
ALTER TABLE public."Plan" ALTER COLUMN status_id SET NOT NULL;
ALTER TABLE IF EXISTS public."Plan" RENAME status_id TO status;
ALTER TABLE public."Description"
ADD COLUMN status_id uuid;
ALTER TABLE public."Description"
ADD CONSTRAINT "Description_status_fkey" FOREIGN KEY (status_id)
REFERENCES public."DescriptionStatus" (id)
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID;
UPDATE public."Description" SET
status_id = '978e6ff6-b5e9-4cee-86cb-bc7401ec4059'
WHERE status = 0;
UPDATE public."Description" SET
status_id = 'c266e2ee-9ae9-4a2f-9b4b-bc6fb1dd54aa'
WHERE status = 1;
UPDATE public."Description" SET
status_id = '60f5e529-7ed3-4be1-8754-ac8c7443f246'
WHERE status = 2;
ALTER TABLE IF EXISTS public."Description" DROP COLUMN IF EXISTS status;
ALTER TABLE public."Description" ALTER COLUMN status_id SET NOT NULL;
ALTER TABLE IF EXISTS public."Description" RENAME status_id TO status;
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.077', '2024-07-29 12:00:00.000000+02', now(), 'Migrate status collumns.');
END$$;