Page MenuHomeSoftware Heritage

Add tests for SQL migrations
Open, NormalPublic

Description

There is currently nothing to test SQL migrations scripts (sql/upgrades/*.sql) before running them in production.

At the very least, we should have automated tests that schemas are correctly upgraded (data are another, harder, issue).

@olasd and I see two possibilities:

  1. Duplicate today's schema on git, and have a test that: 1. applies it 2. applies all migrations added after today 3. compares the resulting DB with the one created from the full schema
  2. Have a CI job reading the Git history that: 1. applies the commit parent's schema 2. applies the new migration 3. compares the DBs

Event Timeline

vlorentz triaged this task as Normal priority.Nov 8 2019, 5:32 PM
vlorentz created this task.
olasd added a comment.Nov 12 2019, 7:02 PM

https://github.com/omniti-labs/pg_extractor is a decent way to extract the schema from a running database into something that's easily diffable