diff --git a/src/server/upgrade/PATCHCreate_ map_overview.sql b/src/server/upgrade/PATCHCreate_ map_overview.sql new file mode 100644 index 00000000..d22fdfa4 --- /dev/null +++ b/src/server/upgrade/PATCHCreate_ map_overview.sql @@ -0,0 +1,33 @@ +-- ============================================================ +-- PATCH: Create map_overview table +-- ============================================================ + +BEGIN; + +CREATE SEQUENCE IF NOT EXISTS public.map_overview_id_seq; + +CREATE TABLE IF NOT EXISTS public.map_overview +( + id INTEGER NOT NULL DEFAULT nextval('map_overview_id_seq'::regclass), + project_id UUID NOT NULL, + version CHARACTER VARYING, + config JSON, + data_location CHARACTER VARYING, + qgis_file CHARACTER VARYING, + + CONSTRAINT pk_map_overview + PRIMARY KEY (id, project_id), + + CONSTRAINT fk_map_overview_project_id_project + FOREIGN KEY (project_id) + REFERENCES public.project (id) + ON DELETE CASCADE +); + +CREATE INDEX IF NOT EXISTS ix_map_overview_project_id + ON public.map_overview (project_id ASC NULLS LAST); + +CREATE INDEX IF NOT EXISTS ix_map_overview_version + ON public.map_overview (version ASC NULLS LAST); + +COMMIT; \ No newline at end of file diff --git a/src/server/upgrade/index.md b/src/server/upgrade/index.md index edef582b..c82a4aa2 100644 --- a/src/server/upgrade/index.md +++ b/src/server/upgrade/index.md @@ -20,23 +20,23 @@ Make sure to always back up your database data before doing a migration. Perform the migration: -0. Fix table - migration from old to new MM version +0. Fix the issue of missing overviews table in case it was not created during older db migration. ```bash $ docker ps -a | grep postgres ``` 2b261cd55de2 postgres:14 "docker-entrypoint.s…" 4 weeks ago Up About a minute 5432/tcp merginmaps-db + ```bash - $ docker exec -it 2b261cd55de2 bash + $ docker exec -it merginmaps-db bash ``` + Run commands in postgres container: + ```bash psql -U postgres ``` - ```bash - select * from project; - ``` ```bash BEGIN;