70 lines
2.8 KiB
SQL
70 lines
2.8 KiB
SQL
DO $$DECLARE
|
|
this_version CONSTANT varchar := '00.01.000';
|
|
BEGIN
|
|
PERFORM * FROM "DBVersion" WHERE version = this_version;
|
|
IF FOUND THEN RETURN; END IF;
|
|
CREATE TABLE public."ReferenceType"
|
|
(
|
|
id uuid NOT NULL,
|
|
name character varying(250) COLLATE pg_catalog."default" NOT NULL,
|
|
code character varying(100) COLLATE pg_catalog."default" NOT NULL,
|
|
definition character varying COLLATE pg_catalog."default" NOT NULL,
|
|
is_active smallint NOT NULL,
|
|
created_at timestamp without time zone NOT NULL,
|
|
updated_at timestamp without time zone NOT NULL,
|
|
CONSTRAINT "ReferenceType_pkey" PRIMARY KEY (id)
|
|
)
|
|
WITH (
|
|
OIDS = FALSE
|
|
);
|
|
|
|
CREATE TABLE public."Reference"
|
|
(
|
|
id uuid NOT NULL,
|
|
label character varying(500) COLLATE pg_catalog."default" NOT NULL,
|
|
description text COLLATE pg_catalog."default",
|
|
abbreviation character varying(50) COLLATE pg_catalog."default",
|
|
source character varying(1024) COLLATE pg_catalog."default",
|
|
is_active smallint NOT NULL,
|
|
created_by uuid,
|
|
created_at timestamp without time zone NOT NULL,
|
|
updated_at timestamp without time zone NOT NULL,
|
|
type uuid NOT NULL,
|
|
definition character varying COLLATE pg_catalog."default",
|
|
reference character varying(1024) COLLATE pg_catalog."default" NOT NULL,
|
|
source_type smallint NOT NULL,
|
|
CONSTRAINT "Reference_pkey" PRIMARY KEY (id),
|
|
CONSTRAINT "Reference_created_by_fkey" FOREIGN KEY (created_by)
|
|
REFERENCES public."UserInfo" (id) MATCH SIMPLE
|
|
ON UPDATE NO ACTION
|
|
ON DELETE NO ACTION
|
|
NOT VALID,
|
|
CONSTRAINT "Reference_type_fkey" FOREIGN KEY (type)
|
|
REFERENCES public."ReferenceType" (id) MATCH SIMPLE
|
|
ON UPDATE NO ACTION
|
|
ON DELETE NO ACTION
|
|
NOT VALID
|
|
)
|
|
WITH (
|
|
OIDS = FALSE
|
|
);
|
|
|
|
CREATE TABLE public."SupportiveMaterial"
|
|
(
|
|
id uuid NOT NULL,
|
|
type smallint NOT NULL,
|
|
language_code character varying(20) COLLATE pg_catalog."default" NOT NULL,
|
|
payload character varying COLLATE pg_catalog."default" NOT NULL,
|
|
created_at timestamp without time zone NOT NULL,
|
|
updated_at timestamp without time zone NOT NULL,
|
|
is_active smallint NOT NULL,
|
|
CONSTRAINT "SupportiveMaterial_pkey" PRIMARY KEY (id)
|
|
)
|
|
WITH (
|
|
OIDS = FALSE
|
|
);
|
|
|
|
|
|
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.000', '2023-11-22 12:00:00.000000+02', now(), 'Add Reference, ReferenceType, SupportiveMaterial');
|
|
|
|
END$$; |