72 lines
2.5 KiB
SQL
72 lines
2.5 KiB
SQL
DO $$DECLARE
|
|
this_version CONSTANT varchar := '00.01.010';
|
|
BEGIN
|
|
PERFORM * FROM "DBVersion" WHERE version = this_version;
|
|
IF FOUND THEN RETURN; END IF;
|
|
|
|
ALTER TABLE public."DescriptionTemplate" RENAME "ID" TO id;
|
|
|
|
ALTER TABLE public."DescriptionTemplate" RENAME "Label" TO label;
|
|
|
|
ALTER TABLE public."DescriptionTemplate" RENAME "Definition" TO definition;
|
|
|
|
ALTER TABLE public."DescriptionTemplate" RENAME "Status" TO status;
|
|
|
|
ALTER TABLE public."DescriptionTemplate" RENAME "Created" TO created_at;
|
|
|
|
ALTER TABLE public."DescriptionTemplate" RENAME "Modified" TO updated_at;
|
|
|
|
ALTER TABLE public."DescriptionTemplate" RENAME "Description" TO description;
|
|
|
|
ALTER TABLE public."DescriptionTemplate" RENAME "GroupId" TO group_id;
|
|
|
|
ALTER TABLE public."DescriptionTemplate" RENAME "Version" TO version;
|
|
|
|
ALTER TABLE public."DescriptionTemplate" RENAME "Language" TO "language";
|
|
|
|
ALTER TABLE public."DescriptionTemplate" RENAME "Type" TO "type";
|
|
|
|
ALTER TABLE public."DescriptionTemplate" ALTER COLUMN created_at TYPE timestamp without time zone ;
|
|
|
|
ALTER TABLE public."DescriptionTemplate" ALTER COLUMN updated_at TYPE timestamp without time zone ;
|
|
|
|
ALTER TABLE public."DescriptionTemplate" ALTER COLUMN group_id DROP DEFAULT;
|
|
|
|
ALTER TABLE public."DescriptionTemplate" ADD COLUMN is_active smallint;
|
|
|
|
UPDATE public."DescriptionTemplate" SET is_active = 1;
|
|
|
|
UPDATE public."DescriptionTemplate" SET is_active = 0 where status = 99;
|
|
UPDATE public."DescriptionTemplate" SET status = 0 where is_active = 0;
|
|
|
|
ALTER TABLE public."DescriptionTemplate" ALTER COLUMN is_active SET NOT NULL;
|
|
|
|
ALTER TABLE public."DescriptionTemplate" ADD COLUMN version_status smallint;
|
|
|
|
UPDATE public."DescriptionTemplate" SET version_status = 1;
|
|
|
|
UPDATE public."DescriptionTemplate" SET version_status = 0 where id in (
|
|
select dt.id from public."DescriptionTemplate" as dt
|
|
where dt.version =
|
|
(
|
|
select Max(f.version)
|
|
from public."DescriptionTemplate" as f where f.group_id=dt.group_id and f.status = 1
|
|
)
|
|
);
|
|
|
|
UPDATE public."DescriptionTemplate" SET version_status = 2 where status = 0 and id in (
|
|
select dt.id from public."DescriptionTemplate" as dt
|
|
where dt.version =
|
|
(
|
|
select Max(f.version)
|
|
from public."DescriptionTemplate" as f where f.group_id=dt.group_id
|
|
)
|
|
);
|
|
|
|
ALTER TABLE public."DescriptionTemplate" ALTER COLUMN version_status SET NOT NULL;
|
|
|
|
ALTER TABLE public."DescriptionTemplate" ALTER COLUMN version DROP DEFAULT;
|
|
|
|
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.010', '2023-11-02 12:00:00.000000+02', now(), 'Aling DescriptionTemplate table.');
|
|
|
|
END$$; |