argos/dmp-db-scema/updates/00.01.005_Add_Dmp_table.sql

45 lines
1.5 KiB
SQL

DO $$DECLARE
this_version CONSTANT varchar := '00.01.005';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
CREATE TABLE public."Dmp"
(
id uuid NOT NULL,
label character varying(250) COLLATE pg_catalog."default" NOT NULL,
version integer NOT NULL,
status smallint NOT NULL DEFAULT 0,
properties text COLLATE pg_catalog."default",
group_id uuid NOT NULL,
description text COLLATE pg_catalog."default",
created_at timestamp without time zone NOT NULL DEFAULT now(),
updated_at timestamp without time zone NOT NULL DEFAULT now(),
is_active smallint NOT NULL DEFAULT 1,
finalized_at timestamp without time zone,
creator uuid NOT NULL,
blueprint uuid NOT NULL,
language character varying(100) COLLATE pg_catalog."default" NOT NULL,
access_type smallint NOT NULL,
public_after timestamp without time zone,
version_status smallint NOT NULL DEFAULT 1,
CONSTRAINT "Dmp_pkey" PRIMARY KEY (id),
CONSTRAINT "Dmp_blueprint_fkey" FOREIGN KEY (blueprint)
REFERENCES public."DmpBlueprint" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID,
CONSTRAINT "Dmp_creator_fkey" FOREIGN KEY (creator)
REFERENCES public."UserInfo" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.005', '2023-10-27 12:00:00.000000+02', now(), 'Add Dmp table.');
END$$;