feat: Add database restore script

This commit is contained in:
2025-09-27 10:00:04 +02:00
parent e3643d8318
commit 19056d5e75
5 changed files with 780 additions and 1 deletions

View File

@@ -24,6 +24,7 @@ class TestContainersConfig {
.withPassword("legalconsenthub")
.withExposedPorts(5432)
.withCreateContainerCmdModifier { cmd ->
cmd.withName("legalconsenthub-backend")
cmd.withHostConfig(
HostConfig().apply {
this.withPortBindings(

View File

@@ -0,0 +1,450 @@
--
-- PostgreSQL database dump
--
-- AG Invitation URL: http://192.168.178.114:3001/accept-invitation/CxVPVaWD0u0hztcwBbV4Pyub0tHIds5o
-- Dumped from database version 17.5
-- Dumped by pg_dump version 17.5
--
-- Force drop all tables and constraints to ensure clean restoration
--
DROP TABLE IF EXISTS public.user_organization_roles CASCADE;
DROP TABLE IF EXISTS public.notification CASCADE;
DROP TABLE IF EXISTS public.form_element_section CASCADE;
DROP TABLE IF EXISTS public.form_element_options CASCADE;
DROP TABLE IF EXISTS public.form_element CASCADE;
DROP TABLE IF EXISTS public.comment CASCADE;
DROP TABLE IF EXISTS public.application_form CASCADE;
DROP TABLE IF EXISTS public.app_user CASCADE;
DROP TABLE IF EXISTS public.databasechangeloglock CASCADE;
DROP TABLE IF EXISTS public.databasechangelog CASCADE;
-- Drop any remaining sequences, views, or other objects
DROP SEQUENCE IF EXISTS public.hibernate_sequence CASCADE;
-- Reset database configuration
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: app_user; Type: TABLE; Schema: public; Owner: legalconsenthub
--
CREATE TABLE public.app_user (
created_at timestamp(6) without time zone NOT NULL,
modified_at timestamp(6) without time zone NOT NULL,
id character varying(255) NOT NULL,
name character varying(255) NOT NULL,
status character varying(255) NOT NULL,
CONSTRAINT app_user_status_check CHECK (((status)::text = ANY ((ARRAY['INVITED'::character varying, 'ACTIVE'::character varying, 'BLOCKED'::character varying, 'SUSPENDED_SUBSCRIPTION'::character varying])::text[])))
);
ALTER TABLE public.app_user OWNER TO legalconsenthub;
--
-- Name: application_form; Type: TABLE; Schema: public; Owner: legalconsenthub
--
CREATE TABLE public.application_form (
is_template boolean NOT NULL,
created_at timestamp(6) without time zone NOT NULL,
modified_at timestamp(6) without time zone NOT NULL,
id uuid NOT NULL,
created_by_id character varying(255) NOT NULL,
last_modified_by_id character varying(255) NOT NULL,
name character varying(255) NOT NULL,
organization_id character varying(255),
status character varying(255) NOT NULL,
CONSTRAINT application_form_status_check CHECK (((status)::text = ANY ((ARRAY['DRAFT'::character varying, 'SUBMITTED'::character varying, 'APPROVED'::character varying, 'REJECTED'::character varying, 'SIGNED'::character varying])::text[])))
);
ALTER TABLE public.application_form OWNER TO legalconsenthub;
--
-- Name: comment; Type: TABLE; Schema: public; Owner: legalconsenthub
--
CREATE TABLE public.comment (
created_at timestamp(6) without time zone NOT NULL,
modified_at timestamp(6) without time zone NOT NULL,
application_form_id uuid NOT NULL,
form_element_id uuid NOT NULL,
id uuid NOT NULL,
created_by_id character varying(255) NOT NULL,
message character varying(255) NOT NULL
);
ALTER TABLE public.comment OWNER TO legalconsenthub;
--
-- Name: databasechangelog; Type: TABLE; Schema: public; Owner: legalconsenthub
--
CREATE TABLE public.databasechangelog (
id character varying(255) NOT NULL,
author character varying(255) NOT NULL,
filename character varying(255) NOT NULL,
dateexecuted timestamp without time zone NOT NULL,
orderexecuted integer NOT NULL,
exectype character varying(10) NOT NULL,
md5sum character varying(35),
description character varying(255),
comments character varying(255),
tag character varying(255),
liquibase character varying(20),
contexts character varying(255),
labels character varying(255),
deployment_id character varying(10)
);
ALTER TABLE public.databasechangelog OWNER TO legalconsenthub;
--
-- Name: databasechangeloglock; Type: TABLE; Schema: public; Owner: legalconsenthub
--
CREATE TABLE public.databasechangeloglock (
id integer NOT NULL,
locked boolean NOT NULL,
lockgranted timestamp without time zone,
lockedby character varying(255)
);
ALTER TABLE public.databasechangeloglock OWNER TO legalconsenthub;
--
-- Name: form_element; Type: TABLE; Schema: public; Owner: legalconsenthub
--
CREATE TABLE public.form_element (
type smallint NOT NULL,
form_element_section_id uuid NOT NULL,
id uuid NOT NULL,
description character varying(255),
title character varying(255),
CONSTRAINT form_element_type_check CHECK (((type >= 0) AND (type <= 4)))
);
ALTER TABLE public.form_element OWNER TO legalconsenthub;
--
-- Name: form_element_options; Type: TABLE; Schema: public; Owner: legalconsenthub
--
CREATE TABLE public.form_element_options (
employee_data_category smallint NOT NULL,
processing_purpose smallint NOT NULL,
form_element_id uuid NOT NULL,
label character varying(255) NOT NULL,
option_value character varying(255) NOT NULL,
CONSTRAINT form_element_options_employee_data_category_check CHECK (((employee_data_category >= 0) AND (employee_data_category <= 3))),
CONSTRAINT form_element_options_processing_purpose_check CHECK (((processing_purpose >= 0) AND (processing_purpose <= 3)))
);
ALTER TABLE public.form_element_options OWNER TO legalconsenthub;
--
-- Name: form_element_section; Type: TABLE; Schema: public; Owner: legalconsenthub
--
CREATE TABLE public.form_element_section (
application_form_id uuid NOT NULL,
id uuid NOT NULL,
description character varying(255),
short_title character varying(255),
title character varying(255) NOT NULL
);
ALTER TABLE public.form_element_section OWNER TO legalconsenthub;
--
-- Name: notification; Type: TABLE; Schema: public; Owner: legalconsenthub
--
CREATE TABLE public.notification (
is_read boolean NOT NULL,
created_at timestamp(6) without time zone NOT NULL,
id uuid NOT NULL,
click_target character varying(255) NOT NULL,
message text NOT NULL,
organization_id character varying(255) NOT NULL,
recipient_id character varying(255),
role character varying(255) NOT NULL,
title character varying(255) NOT NULL,
type character varying(255) NOT NULL,
CONSTRAINT notification_type_check CHECK (((type)::text = ANY ((ARRAY['INFO'::character varying, 'WARNING'::character varying, 'ERROR'::character varying])::text[])))
);
ALTER TABLE public.notification OWNER TO legalconsenthub;
--
-- Name: user_organization_roles; Type: TABLE; Schema: public; Owner: legalconsenthub
--
CREATE TABLE public.user_organization_roles (
organization_id character varying(255) NOT NULL,
role character varying(255) NOT NULL,
user_id character varying(255) NOT NULL
);
ALTER TABLE public.user_organization_roles OWNER TO legalconsenthub;
--
-- Data for Name: app_user; Type: TABLE DATA; Schema: public; Owner: legalconsenthub
--
COPY public.app_user (created_at, modified_at, id, name, status) FROM stdin;
2025-09-27 08:25:18.821058 2025-09-27 08:25:18.845236 umgS7DllaoSY17iNDK2FizXKeGJHQs2g Denis Lugowski ACTIVE
2025-09-27 08:26:08.333312 2025-09-27 08:26:08.335975 wMZ2SEChna9CdzLOhwfZ3Qb5vxh5YUmD BR ACTIVE
2025-09-27 08:27:28.27983 2025-09-27 08:27:28.282089 ZHbzeqHRYWe2USuDQuIHINAL22EjXVyb AG ACTIVE
\.
--
-- Data for Name: application_form; Type: TABLE DATA; Schema: public; Owner: legalconsenthub
--
COPY public.application_form (is_template, created_at, modified_at, id, created_by_id, last_modified_by_id, name, organization_id, status) FROM stdin;
\.
--
-- Data for Name: comment; Type: TABLE DATA; Schema: public; Owner: legalconsenthub
--
COPY public.comment (created_at, modified_at, application_form_id, form_element_id, id, created_by_id, message) FROM stdin;
\.
--
-- Data for Name: databasechangelog; Type: TABLE DATA; Schema: public; Owner: legalconsenthub
--
COPY public.databasechangelog (id, author, filename, dateexecuted, orderexecuted, exectype, md5sum, description, comments, tag, liquibase, contexts, labels, deployment_id) FROM stdin;
raw includeAll db/migrations/001-schema.sql 2025-09-27 08:24:34.933234 1 EXECUTED 9:1ffb09d62ed861ad7fac642fc83efeaf sql \N 4.29.2 \N \N 8954274880
\.
--
-- Data for Name: databasechangeloglock; Type: TABLE DATA; Schema: public; Owner: legalconsenthub
--
COPY public.databasechangeloglock (id, locked, lockgranted, lockedby) FROM stdin;
1 f \N \N
\.
--
-- Data for Name: form_element; Type: TABLE DATA; Schema: public; Owner: legalconsenthub
--
COPY public.form_element (type, form_element_section_id, id, description, title) FROM stdin;
\.
--
-- Data for Name: form_element_options; Type: TABLE DATA; Schema: public; Owner: legalconsenthub
--
COPY public.form_element_options (employee_data_category, processing_purpose, form_element_id, label, option_value) FROM stdin;
\.
--
-- Data for Name: form_element_section; Type: TABLE DATA; Schema: public; Owner: legalconsenthub
--
COPY public.form_element_section (application_form_id, id, description, short_title, title) FROM stdin;
\.
--
-- Data for Name: notification; Type: TABLE DATA; Schema: public; Owner: legalconsenthub
--
COPY public.notification (is_read, created_at, id, click_target, message, organization_id, recipient_id, role, title, type) FROM stdin;
\.
--
-- Data for Name: user_organization_roles; Type: TABLE DATA; Schema: public; Owner: legalconsenthub
--
COPY public.user_organization_roles (organization_id, role, user_id) FROM stdin;
AHA19yfn1CQW3gzsbtFRIpqKZUQqbh9V works_council_member wMZ2SEChna9CdzLOhwfZ3Qb5vxh5YUmD
\.
--
-- Name: app_user app_user_pkey; Type: CONSTRAINT; Schema: public; Owner: legalconsenthub
--
ALTER TABLE ONLY public.app_user
ADD CONSTRAINT app_user_pkey PRIMARY KEY (id);
--
-- Name: application_form application_form_pkey; Type: CONSTRAINT; Schema: public; Owner: legalconsenthub
--
ALTER TABLE ONLY public.application_form
ADD CONSTRAINT application_form_pkey PRIMARY KEY (id);
--
-- Name: comment comment_pkey; Type: CONSTRAINT; Schema: public; Owner: legalconsenthub
--
ALTER TABLE ONLY public.comment
ADD CONSTRAINT comment_pkey PRIMARY KEY (id);
--
-- Name: databasechangeloglock databasechangeloglock_pkey; Type: CONSTRAINT; Schema: public; Owner: legalconsenthub
--
ALTER TABLE ONLY public.databasechangeloglock
ADD CONSTRAINT databasechangeloglock_pkey PRIMARY KEY (id);
--
-- Name: form_element form_element_pkey; Type: CONSTRAINT; Schema: public; Owner: legalconsenthub
--
ALTER TABLE ONLY public.form_element
ADD CONSTRAINT form_element_pkey PRIMARY KEY (id);
--
-- Name: form_element_section form_element_section_pkey; Type: CONSTRAINT; Schema: public; Owner: legalconsenthub
--
ALTER TABLE ONLY public.form_element_section
ADD CONSTRAINT form_element_section_pkey PRIMARY KEY (id);
--
-- Name: notification notification_pkey; Type: CONSTRAINT; Schema: public; Owner: legalconsenthub
--
ALTER TABLE ONLY public.notification
ADD CONSTRAINT notification_pkey PRIMARY KEY (id);
--
-- Name: user_organization_roles user_organization_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: legalconsenthub
--
ALTER TABLE ONLY public.user_organization_roles
ADD CONSTRAINT user_organization_roles_pkey PRIMARY KEY (organization_id, role, user_id);
--
-- Name: application_form fk5yewx8bespw0uiivxioeh7q0d; Type: FK CONSTRAINT; Schema: public; Owner: legalconsenthub
--
ALTER TABLE ONLY public.application_form
ADD CONSTRAINT fk5yewx8bespw0uiivxioeh7q0d FOREIGN KEY (last_modified_by_id) REFERENCES public.app_user(id);
--
-- Name: comment fkbbjqikfmgeacfsnaasxxqoygh; Type: FK CONSTRAINT; Schema: public; Owner: legalconsenthub
--
ALTER TABLE ONLY public.comment
ADD CONSTRAINT fkbbjqikfmgeacfsnaasxxqoygh FOREIGN KEY (created_by_id) REFERENCES public.app_user(id);
--
-- Name: form_element fkdpr6k93m4hqllqjsvoa4or6mp; Type: FK CONSTRAINT; Schema: public; Owner: legalconsenthub
--
ALTER TABLE ONLY public.form_element
ADD CONSTRAINT fkdpr6k93m4hqllqjsvoa4or6mp FOREIGN KEY (form_element_section_id) REFERENCES public.form_element_section(id);
--
-- Name: notification fkeg1j4hnp0y4lbm0y35hgr4e8r; Type: FK CONSTRAINT; Schema: public; Owner: legalconsenthub
--
ALTER TABLE ONLY public.notification
ADD CONSTRAINT fkeg1j4hnp0y4lbm0y35hgr4e8r FOREIGN KEY (recipient_id) REFERENCES public.app_user(id);
--
-- Name: comment fkfg84w0i76tw9os13950272c6f; Type: FK CONSTRAINT; Schema: public; Owner: legalconsenthub
--
ALTER TABLE ONLY public.comment
ADD CONSTRAINT fkfg84w0i76tw9os13950272c6f FOREIGN KEY (form_element_id) REFERENCES public.form_element(id);
--
-- Name: user_organization_roles fkhgmm93qre3up6hy63wcef3yqk; Type: FK CONSTRAINT; Schema: public; Owner: legalconsenthub
--
ALTER TABLE ONLY public.user_organization_roles
ADD CONSTRAINT fkhgmm93qre3up6hy63wcef3yqk FOREIGN KEY (user_id) REFERENCES public.app_user(id);
--
-- Name: application_form fkhtad5onoy2jknhtyfmx6cvvey; Type: FK CONSTRAINT; Schema: public; Owner: legalconsenthub
--
ALTER TABLE ONLY public.application_form
ADD CONSTRAINT fkhtad5onoy2jknhtyfmx6cvvey FOREIGN KEY (created_by_id) REFERENCES public.app_user(id);
--
-- Name: comment fklavy9axrt26sepreg5lqtuoap; Type: FK CONSTRAINT; Schema: public; Owner: legalconsenthub
--
ALTER TABLE ONLY public.comment
ADD CONSTRAINT fklavy9axrt26sepreg5lqtuoap FOREIGN KEY (application_form_id) REFERENCES public.application_form(id);
--
-- Name: form_element_options fknq0lpby5nspv1xi27n9el6us6; Type: FK CONSTRAINT; Schema: public; Owner: legalconsenthub
--
ALTER TABLE ONLY public.form_element_options
ADD CONSTRAINT fknq0lpby5nspv1xi27n9el6us6 FOREIGN KEY (form_element_id) REFERENCES public.form_element(id);
--
-- Name: form_element_section fktn0lreovauwf2v29doo70o3qs; Type: FK CONSTRAINT; Schema: public; Owner: legalconsenthub
--
ALTER TABLE ONLY public.form_element_section
ADD CONSTRAINT fktn0lreovauwf2v29doo70o3qs FOREIGN KEY (application_form_id) REFERENCES public.application_form(id);
--
-- PostgreSQL database dump complete
--