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

Dry run migrations. #50

Open
igalklebanov opened this issue Jun 27, 2024 · 3 comments
Open

Dry run migrations. #50

igalklebanov opened this issue Jun 27, 2024 · 3 comments
Labels
enhancement New feature or request migrate Migrate module related

Comments

@igalklebanov
Copy link
Member

igalklebanov commented Jun 27, 2024

Hey 👋

What if we could dry-run migrations?

@igalklebanov igalklebanov added enhancement New feature or request migrate Migrate module related labels Jun 27, 2024
@shane-js
Copy link

shane-js commented Jun 28, 2024

So awesome to see this presented as a possibility after our talk yesterday. I'll share what I wrote there:

[Without this my] current thought is the only way to test is by wiping the DB completely (or point to a different one) and re-backing it up to compare the schema of the rewritten kysely migration to the original schema created by the knex migration.

I've always longed for something like Entity Framework how it can compare and show diffs before executing.

Although I am guessing technically this would only be possible incrementally with each currently unrun migration file - it would be insanely great if it could output what the final diffs would be after all migrations something like (example of edit column, delete column, and insert column only others would need thought out):

UserTable:

  • first_name varchar(255) ✏️ varchar(1000)
  • midd1e_name varchar(1000) -> ❌
  • middle_name varchar(1000) -> ✅

I honestly think something like this would be extremely well received and attract a lot of people to this tech if it could be figured out.

@EloB
Copy link

EloB commented Oct 30, 2024

Is this considered? Would love to have such feature. Just to see all queries that would be executed before I run them.

@shane-js Like your stuff as well but just able to see what will be executed in SQL would be amazing.

@igalklebanov
Copy link
Member Author

igalklebanov commented Oct 30, 2024

This could work for databases that support transactional DDL.

Run the command and rollback, while logging what ran.

For others, not sure yet, maybe setup a shadow/in-memory database to run against. Maybe just a temporary schema on the existing one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request migrate Migrate module related
Projects
None yet
Development

No branches or pull requests

3 participants