Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/server/upgrade/PATCHCreate_ map_overview.sql
Original file line number Diff line number Diff line change
@@ -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;
10 changes: 5 additions & 5 deletions src/server/upgrade/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could go to the step where migrations are running - no step 0. You need to double check if map_overviews table is there and if not just run sql.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be a good idea to fix this before running the migration so that there is no error message about the missing table.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this table fix belongs to 2025.7.3 migration as that is the one which relies on that missing table (and potentially also newer ones).


```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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably just add link to public repository sql.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I can only upload the link to download the SQL file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we discussed that and for convenience I would keep it in docs, that's the source where admins are copy pasting commands

BEGIN;

Expand Down
Loading