Skip to content

Want a way to test data migrations #4747

@david-crespo

Description

@david-crespo

While working on #4261, I found it hard to get confidence in my data migrations using existing tooling. One thing I found helpful was using DB Fiddle to write some similar tables and running similar migrations on them to make sure I got the expected results.

https://www.db-fiddle.com/f/pzmM69My6mZWq1NEKm56PG/1

However, this is lacking in ways that formal tooling could improve on:

  1. It's Postgres 15, not CRDB, and especially not the version of CRDB we're running
  2. The tables are simplified because making them match exactly is annoying to do by hand, even though it would be easy to do automatically

So what I have in mind is essentially a way of:

  1. Running migrations up to but not including the one under test
  2. Running some SQL to insert rows in the DB
  3. Running the migration under test
  4. Asserting stuff about the resulting DB state

Metadata

Metadata

Assignees

Labels

Testing & AnalysisTests & AnalyzersdatabaseRelated to database accessdevelopmentBugs, paper cuts, feature requests, or other thoughts on making omicron development better

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions