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

Adds ability to apply migrations without versioning #291

Merged
merged 11 commits into from
Dec 13, 2021
Merged

Conversation

mfridman
Copy link
Collaborator

@mfridman mfridman commented Dec 3, 2021

Closes #259.

This implementation adds no-versioning support to all existing commands, effectively treating the provided directory as a source of truth. There should be no behaviour changes to existing (versioned) migrations.

No version means "apply migrations without tracking them in the schema table".

A common use case might be (see linked ticker for even more context):

  1. Apply versioned migrations
  2. Apply not versioned seed data (from a different directory)
  3. Reset the database by migrating all the seed data down

There are some limitations of no-versioning because we're not storing the history of applied migrations. Example:

Say you have 5 seed migrations and are running the following commands repeatedly: down will only ever apply the last migration down. Running up-by-one will only ever apply the first migration up. Also, running up-to and then a down-to won't work, since all unversioned migrations start at either the first or last migration.

This limitation is expected, and most users will likely run up followed by reset with the --no-versioning flag (CLI) or WithNoVersioning() library functional option.

  • Fix output to make sense when versioning is disabled
  • Add e2e tests for seeding / checking both up and down commands

@mfridman mfridman force-pushed the no-versioning branch 2 times, most recently from 4e84252 to 5fece2b Compare December 12, 2021 03:37
@mfridman mfridman marked this pull request as ready for review December 12, 2021 03:37
@mfridman mfridman merged commit c8aa123 into master Dec 13, 2021
@mfridman mfridman deleted the no-versioning branch December 13, 2021 05:37
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.

Add support for seeding the database with test data
1 participant