Skip to content

Squash migrations V1-V26 into one initial schema - #14

Merged
op-techy merged 1 commit into
mainfrom
chore/squash-migrations
Dec 3, 2026
Merged

op-techy merged 1 commit into
mainfrom
chore/squash-migrations

Conversation

@op-techy

@op-techy op-techy commented Dec 3, 2026

Copy link
Copy Markdown
Owner

Replaces the 26 Flyway migrations with a single V1__initial_schema.sql describing the schema as it is now. The history of tables created and then altered, the account/multi-tenancy columns added and dropped, the admin password fixed in V23 and the foreign keys redone in V24/V26 is gone.

Is it the same schema?

I applied the old V1–V26 to one empty Postgres 16 database and the new V1 to another, then diffed pg_dump --schema-only. They match exactly (tables, column order and types, defaults, check constraints, foreign keys with their delete rules, unique constraints, indexes, constraint names), except for one intended change:

  • idx_evt_token and idx_prt_token are gone. They repeated the indexes Postgres already builds for the UNIQUE (token) constraints, so every token write updated two identical indexes.

The seeded admin row is identical too (same values, including the working ChangeMe123! hash and must_change_pwd = true).

⚠️ Existing databases

Any database created with the old migrations must be dropped and recreated. Flyway would refuse to start on it, because its history lists V2–V26, which no longer exist, and a V1 with a different checksum. Agreed beforehand: no database needs keeping.

Also

  • README: migration list, "adding a migration" (next file is V2__…), seeded-admin note.
  • Comments that pointed at V21/V26.

Testing

  • Unit 356/356, integration 38/38, scale 9/9 (Testcontainers start from the new V1).
  • Docker image built; Flyway applied the 1 migration and the end-to-end sweep passed 68/68 with no ERROR lines in the log.

V1__initial_schema.sql creates the schema the 26 migrations produced, plus the
seeded admin with the working password hash. Verified by applying both to
empty databases and diffing pg_dump output: identical apart from dropping
idx_evt_token and idx_prt_token, which duplicated the indexes behind the
UNIQUE (token) constraints.

Existing databases are not migrated: they must be dropped and recreated.
@op-techy
op-techy merged commit 7c7f82b into main Dec 3, 2026
2 checks passed
@op-techy
op-techy deleted the chore/squash-migrations branch December 3, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant