From d2d601338927e5973adba8be0698791d00b174dd Mon Sep 17 00:00:00 2001 From: amentis Date: Tue, 5 Dec 2023 16:57:06 +0200 Subject: [PATCH] add more sql scripts for Notification service --- .../00.01.033_addNTFInAppNotification.sql | 37 +++++++++++++++++++ ...1.034_addNTFUserNotificationPreference.sql | 30 +++++++++++++++ .../00.01.035_addNTFTenantConfiguration.sql | 26 +++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 dmp-db-scema/updates/00.01.033_addNTFInAppNotification.sql create mode 100644 dmp-db-scema/updates/00.01.034_addNTFUserNotificationPreference.sql create mode 100644 dmp-db-scema/updates/00.01.035_addNTFTenantConfiguration.sql diff --git a/dmp-db-scema/updates/00.01.033_addNTFInAppNotification.sql b/dmp-db-scema/updates/00.01.033_addNTFInAppNotification.sql new file mode 100644 index 000000000..970c55628 --- /dev/null +++ b/dmp-db-scema/updates/00.01.033_addNTFInAppNotification.sql @@ -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$$; \ No newline at end of file diff --git a/dmp-db-scema/updates/00.01.034_addNTFUserNotificationPreference.sql b/dmp-db-scema/updates/00.01.034_addNTFUserNotificationPreference.sql new file mode 100644 index 000000000..8c53d7f4d --- /dev/null +++ b/dmp-db-scema/updates/00.01.034_addNTFUserNotificationPreference.sql @@ -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$$; \ No newline at end of file diff --git a/dmp-db-scema/updates/00.01.035_addNTFTenantConfiguration.sql b/dmp-db-scema/updates/00.01.035_addNTFTenantConfiguration.sql new file mode 100644 index 000000000..4c4211735 --- /dev/null +++ b/dmp-db-scema/updates/00.01.035_addNTFTenantConfiguration.sql @@ -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$$; \ No newline at end of file