add more sql scripts for Notification service

This commit is contained in:
amentis 2023-12-05 16:57:06 +02:00
parent 2fb99d2fe7
commit d2d6013389
3 changed files with 93 additions and 0 deletions

View File

@ -0,0 +1,37 @@
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$$;

View File

@ -0,0 +1,30 @@
DO $$DECLARE
this_version CONSTANT varchar := '00.01.034';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
CREATE TABLE public."NTFUserNotificationPreference"
(
"user" uuid NOT NULL,
type uuid NOT NULL,
channel smallint NOT NULL,
ordinal numeric NOT NULL,
created_at timestamp without time zone NOT NULL,
tenant uuid,
CONSTRAINT "NTFUserNotificationPreference_pkey" PRIMARY KEY ("user", type, channel),
CONSTRAINT "NTFUserNotificationPreference_tennant_fkey" FOREIGN KEY (tenant)
REFERENCES public."Tenant" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID,
CONSTRAINT "NTFUserNotificationPreference_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.034', '2023-12-05 12:00:00.000000+02', now(), 'Add table NTFUserNotificationPreference.');
END$$;

View File

@ -0,0 +1,26 @@
DO $$DECLARE
this_version CONSTANT varchar := '00.01.035';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
CREATE TABLE public."NTFTenantConfiguration"
(
id uuid NOT NULL,
tenant uuid NOT NULL,
type smallint NOT NULL,
value character varying NOT NULL,
is_active smallint NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
CONSTRAINT "NTFTenantConfguration_pkey" PRIMARY KEY (id),
CONSTRAINT "NTFTenantConfiguration_tenant_fkey" FOREIGN KEY (tenant)
REFERENCES public."Tenant" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID
);
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.035', '2023-12-05 12:00:00.000000+02', now(), 'Add table NTFTenantConfiguration.');
END$$;