argos/dmp-db-scema/updates/00.01.033_addNTFInAppNotifi...

37 lines
1.3 KiB
SQL

DO $$DECLARE
this_version CONSTANT varchar := '00.01.033';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
CREATE TABLE public."NTFInAppNotification"
(
id uuid NOT NULL,
"user" uuid NOT NULL,
is_active timestamp without time zone NOT NULL,
type uuid NOT NULL,
read_time timestamp without time zone,
tracking_state smallint NOT NULL,
priority smallint NOT NULL,
subject character varying,
body character varying,
extra_data character varying,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
tenant uuid,
CONSTRAINT "NTFInAppNotification_pkey" PRIMARY KEY (id),
CONSTRAINT "NTFInAppNotification_tenant_fkey" FOREIGN KEY (tenant)
REFERENCES public."Tenant" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID,
CONSTRAINT "NTFInAppNotification_user_fkey" FOREIGN KEY ("user")
REFERENCES public."User" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID
);
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.033', '2023-12-05 12:00:00.000000+02', now(), 'Add table NTFInAppNotification.');
END$$;