From a65ca49c0bbe8e113bfd448efa8bf43f782ae0ff Mon Sep 17 00:00:00 2001
From: Lars Johansson <lars.johansson@ess.eu>
Date: Mon, 3 Jun 2024 16:14:42 +0200
Subject: [PATCH] Drop table for usernames for notifications

Drop table for usernames for notifications as it is no longer used
and replaced by configurable properties for list of email addresses
for notifications.
---
 docker-compose-integrationtest.yml            |  1 +
 docs/todo_for_first_releases.txt              |  6 +-
 .../V7__Remove_user_notification_cc_list.sql  | 18 +++++
 .../data/db/dump-discs_names_namesit.sql      | 70 -------------------
 .../data/db/dump-discs_names_subsystemit.sql  | 70 -------------------
 5 files changed, 24 insertions(+), 141 deletions(-)
 create mode 100644 src/main/resources/db/migration/V7__Remove_user_notification_cc_list.sql

diff --git a/docker-compose-integrationtest.yml b/docker-compose-integrationtest.yml
index e5969840..ac8741a2 100644
--- a/docker-compose-integrationtest.yml
+++ b/docker-compose-integrationtest.yml
@@ -49,6 +49,7 @@ services:
       - ./src/main/resources/db/migration/V4__Schema_data_migration.sql:/docker-entrypoint-initdb.d/V4__Schema_data_migration.sql
       - ./src/main/resources/db/migration/V5.2__Data_transformation_status_deleted.sql:/docker-entrypoint-initdb.d/V5.2__Data_transformation_status_deleted.sql
       - ./src/main/resources/db/migration/V6.2__Schema_data_migration_audit.sql:/docker-entrypoint-initdb.d/V6.2__Schema_data_migration_audit.sql
+      - ./src/main/resources/db/migration/V7__Remove_user_notification_cc_list.sql:/docker-entrypoint-initdb.d/V7__Remove_user_notification_cc_list.sql
 
 volumes:
   naming-data:
diff --git a/docs/todo_for_first_releases.txt b/docs/todo_for_first_releases.txt
index 397b2658..988be377 100644
--- a/docs/todo_for_first_releases.txt
+++ b/docs/todo_for_first_releases.txt
@@ -174,7 +174,6 @@ Note
                                 subsystem
                                 system
                                 systemgroup
-                                user_notification
                         other
                             related to wip tables -- see also V4__Schema_data_migration.sql
                             indices
@@ -184,6 +183,11 @@ Note
         6. flyway            - introduce
                 6.1 possibly use existing table flyway_schema_history or create a new table
                 6.2 introduce flyway and make use of new migration script V1__*.sql - see 5.1 - decide on flyway table
+                6.3 update integration tests accordingly
+                        docker-compose-integrationtest.yml
+                            postgres:
+                              volumes:
+                                - ./src/main/resources/db/migration/V1__*.sql:/docker-entrypoint-initdb.d/V1__*.sql
         7. release           - release & deploy
         8. post              - open & use
                 8.1 open Naming (new)
diff --git a/src/main/resources/db/migration/V7__Remove_user_notification_cc_list.sql b/src/main/resources/db/migration/V7__Remove_user_notification_cc_list.sql
new file mode 100644
index 00000000..b5f30ef2
--- /dev/null
+++ b/src/main/resources/db/migration/V7__Remove_user_notification_cc_list.sql
@@ -0,0 +1,18 @@
+-- ----------------------------------------------------------------------------------------------------
+-- About
+--     migration script
+--     postgresql 9.6.7
+-- Content
+--     user notification table
+-- Note
+--     remove table as it is no longer used
+--     users to which to send notifications to be handled by configuration
+-- ----------------------------------------------------------------------------------------------------
+
+-- ----------------------------------------------------------------------------------------------------
+-- user notification
+-- ----------------------------------------------------------------------------------------------------
+ALTER TABLE ONLY user_notification
+   DROP CONSTRAINT user_notification_pk;
+
+DROP TABLE user_notification;
diff --git a/src/test/resources/data/db/dump-discs_names_namesit.sql b/src/test/resources/data/db/dump-discs_names_namesit.sql
index bc35e385..657ca34b 100644
--- a/src/test/resources/data/db/dump-discs_names_namesit.sql
+++ b/src/test/resources/data/db/dump-discs_names_namesit.sql
@@ -738,40 +738,6 @@ CREATE SEQUENCE public.systemgroup_id_seq
 ALTER SEQUENCE public.systemgroup_id_seq OWNED BY public.systemgroup.id;
 
 
---
--- TOC entry 198 (class 1259 OID 16488)
--- Name: user_notification; Type: TABLE; Schema: public; Owner: -
---
-
-CREATE TABLE public.user_notification (
-    id bigint NOT NULL,
-    notification_type character varying(32) NOT NULL,
-    user_login_name character varying(32) NOT NULL
-);
-
-
---
--- TOC entry 197 (class 1259 OID 16486)
--- Name: user_notification_id_seq; Type: SEQUENCE; Schema: public; Owner: -
---
-
-CREATE SEQUENCE public.user_notification_id_seq
-    START WITH 1
-    INCREMENT BY 1
-    NO MINVALUE
-    NO MAXVALUE
-    CACHE 1;
-
-
---
--- TOC entry 2364 (class 0 OID 0)
--- Dependencies: 197
--- Name: user_notification_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
---
-
-ALTER SEQUENCE public.user_notification_id_seq OWNED BY public.user_notification.id;
-
-
 --
 -- TOC entry 195 (class 1259 OID 16420)
 -- Name: useraccount; Type: TABLE; Schema: public; Owner: -
@@ -903,14 +869,6 @@ ALTER TABLE ONLY public.system ALTER COLUMN id SET DEFAULT nextval('public.syste
 ALTER TABLE ONLY public.systemgroup ALTER COLUMN id SET DEFAULT nextval('public.systemgroup_id_seq'::regclass);
 
 
---
--- TOC entry 2107 (class 2604 OID 16491)
--- Name: user_notification id; Type: DEFAULT; Schema: public; Owner: -
---
-
-ALTER TABLE ONLY public.user_notification ALTER COLUMN id SET DEFAULT nextval('public.user_notification_id_seq'::regclass);
-
-
 --
 -- TOC entry 2106 (class 2604 OID 16433)
 -- Name: useraccount id; Type: DEFAULT; Schema: public; Owner: -
@@ -1175,25 +1133,6 @@ COPY public.systemgroup (id, version, uuid, mnemonic, mnemonic_equivalence, orde
 SELECT pg_catalog.setval('public.systemgroup_id_seq', 1, true);
 
 
---
--- TOC entry 2331 (class 0 OID 16488)
--- Dependencies: 198
--- Data for Name: user_notification; Type: TABLE DATA; Schema: public; Owner: -
---
-
-COPY public.user_notification (id, notification_type, user_login_name) FROM stdin;
-\.
-
-
---
--- TOC entry 2378 (class 0 OID 0)
--- Dependencies: 197
--- Name: user_notification_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
---
-
-SELECT pg_catalog.setval('public.user_notification_id_seq', 1, false);
-
-
 --
 -- TOC entry 2328 (class 0 OID 16420)
 -- Dependencies: 195
@@ -1321,15 +1260,6 @@ ALTER TABLE ONLY public.systemgroup
     ADD CONSTRAINT systemgroup_pk PRIMARY KEY (id);
 
 
---
--- TOC entry 2128 (class 2606 OID 16493)
--- Name: user_notification user_notification_pk; Type: CONSTRAINT; Schema: public; Owner: -
---
-
-ALTER TABLE ONLY public.user_notification
-    ADD CONSTRAINT user_notification_pk PRIMARY KEY (id);
-
-
 --
 -- TOC entry 2126 (class 2606 OID 16445)
 -- Name: useraccount useraccount_pkey; Type: CONSTRAINT; Schema: public; Owner: -
diff --git a/src/test/resources/data/db/dump-discs_names_subsystemit.sql b/src/test/resources/data/db/dump-discs_names_subsystemit.sql
index f6d43329..acb16973 100644
--- a/src/test/resources/data/db/dump-discs_names_subsystemit.sql
+++ b/src/test/resources/data/db/dump-discs_names_subsystemit.sql
@@ -738,40 +738,6 @@ CREATE SEQUENCE public.systemgroup_id_seq
 ALTER SEQUENCE public.systemgroup_id_seq OWNED BY public.systemgroup.id;
 
 
---
--- TOC entry 198 (class 1259 OID 16488)
--- Name: user_notification; Type: TABLE; Schema: public; Owner: -
---
-
-CREATE TABLE public.user_notification (
-    id bigint NOT NULL,
-    notification_type character varying(32) NOT NULL,
-    user_login_name character varying(32) NOT NULL
-);
-
-
---
--- TOC entry 197 (class 1259 OID 16486)
--- Name: user_notification_id_seq; Type: SEQUENCE; Schema: public; Owner: -
---
-
-CREATE SEQUENCE public.user_notification_id_seq
-    START WITH 1
-    INCREMENT BY 1
-    NO MINVALUE
-    NO MAXVALUE
-    CACHE 1;
-
-
---
--- TOC entry 2364 (class 0 OID 0)
--- Dependencies: 197
--- Name: user_notification_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
---
-
-ALTER SEQUENCE public.user_notification_id_seq OWNED BY public.user_notification.id;
-
-
 --
 -- TOC entry 195 (class 1259 OID 16420)
 -- Name: useraccount; Type: TABLE; Schema: public; Owner: -
@@ -903,14 +869,6 @@ ALTER TABLE ONLY public.system ALTER COLUMN id SET DEFAULT nextval('public.syste
 ALTER TABLE ONLY public.systemgroup ALTER COLUMN id SET DEFAULT nextval('public.systemgroup_id_seq'::regclass);
 
 
---
--- TOC entry 2107 (class 2604 OID 16491)
--- Name: user_notification id; Type: DEFAULT; Schema: public; Owner: -
---
-
-ALTER TABLE ONLY public.user_notification ALTER COLUMN id SET DEFAULT nextval('public.user_notification_id_seq'::regclass);
-
-
 --
 -- TOC entry 2106 (class 2604 OID 16433)
 -- Name: useraccount id; Type: DEFAULT; Schema: public; Owner: -
@@ -1282,25 +1240,6 @@ COPY public.systemgroup (id, version, uuid, mnemonic, mnemonic_equivalence, orde
 SELECT pg_catalog.setval('public.systemgroup_id_seq', 1, true);
 
 
---
--- TOC entry 2331 (class 0 OID 16488)
--- Dependencies: 198
--- Data for Name: user_notification; Type: TABLE DATA; Schema: public; Owner: -
---
-
-COPY public.user_notification (id, notification_type, user_login_name) FROM stdin;
-\.
-
-
---
--- TOC entry 2378 (class 0 OID 0)
--- Dependencies: 197
--- Name: user_notification_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
---
-
-SELECT pg_catalog.setval('public.user_notification_id_seq', 1, false);
-
-
 --
 -- TOC entry 2328 (class 0 OID 16420)
 -- Dependencies: 195
@@ -1428,15 +1367,6 @@ ALTER TABLE ONLY public.systemgroup
     ADD CONSTRAINT systemgroup_pk PRIMARY KEY (id);
 
 
---
--- TOC entry 2128 (class 2606 OID 16493)
--- Name: user_notification user_notification_pk; Type: CONSTRAINT; Schema: public; Owner: -
---
-
-ALTER TABLE ONLY public.user_notification
-    ADD CONSTRAINT user_notification_pk PRIMARY KEY (id);
-
-
 --
 -- TOC entry 2126 (class 2606 OID 16445)
 -- Name: useraccount useraccount_pkey; Type: CONSTRAINT; Schema: public; Owner: -
-- 
GitLab