Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test framework for SQL DB migrations #694

Closed
ffranr opened this issue Nov 21, 2023 · 1 comment · Fixed by #707
Closed

Add test framework for SQL DB migrations #694

ffranr opened this issue Nov 21, 2023 · 1 comment · Fixed by #707
Assignees
Labels
enhancement New feature or request sqlc testing
Milestone

Comments

@ffranr
Copy link
Contributor

ffranr commented Nov 21, 2023

This project currently lacks a test framework for SQL database migration changes.

Our migrations are incremental and are stored in order here: ./tapdb/sqlc/migrations/*.sql

Currently, in testing, we simply apply all migrations and then use the resultant DB. We should add the capability to apply a subset of the migration changes and then allow an opportunity for test code to examine the DB.

@guggero
Copy link
Member

guggero commented Nov 27, 2023

I think we can make this quite simple for us: In NewTestPostgresDB (or NewTestSqliteDB), if an optional initialDataFileName parameter is specified, we would read that file as SQL and run the statements inside against the DB before creating the store (which then applies the migrations).
So if the initial data file contains a full SQL DB dump (including the table that the migrations library uses to keep track of what migrations have already been applied), then we can test certain incremental migrations.
The initial data files might be a bit hard to maintain manually, but ideally we create them from an actual DB once and then don't have to update them.
Maybe we need separate files for Postgres and SQLite, or maybe we can apply the same text search/replace mappings we use during the migrations themselves.

@Roasbeef Roasbeef added this to the v0.4 milestone Nov 28, 2023
@github-project-automation github-project-automation bot moved this from 💇‍♂️Needs Shaping to 🆕 New in Taproot-Assets Project Board Nov 28, 2023
@Roasbeef Roasbeef moved this to 💇‍♂️Needs Shaping in Taproot-Assets Project Board Nov 28, 2023
@Roasbeef Roasbeef moved this from 🆕 New to 🔖 Ready in Taproot-Assets Project Board Nov 28, 2023
@Roasbeef Roasbeef moved this from 🔖 Ready to 💇‍♂️Needs Shaping in Taproot-Assets Project Board Nov 28, 2023
@guggero guggero moved this from 💇‍♂️Needs Shaping to 🏗 In progress in Taproot-Assets Project Board Nov 29, 2023
@guggero guggero moved this from 🏗 In progress to 👀 In review in Taproot-Assets Project Board Nov 30, 2023
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in Taproot-Assets Project Board Dec 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request sqlc testing
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

3 participants