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

Migrations can be modified without notice #984

Open
niklas-e opened this issue May 8, 2024 · 3 comments
Open

Migrations can be modified without notice #984

niklas-e opened this issue May 8, 2024 · 3 comments
Labels
enhancement New feature or request migrations Related to migrations

Comments

@niklas-e
Copy link

niklas-e commented May 8, 2024

Description:

I noticed migrator stores only the migration name into db. Therefore if there's any changes in migrations, you wouldn't notice it in environments where you have ran them already.

Expected behaviour:

Migrator throws an error if the current migration contents do not match already ran migrations.

Possible solution:

This could be potentially solved by adding a checksum of the migration to the migration table and verifying it while running migrations.

@alenap93
Copy link
Contributor

alenap93 commented May 8, 2024

I think that a solution could be a checksum system like liquibase

@igalklebanov igalklebanov added enhancement New feature or request migrations Related to migrations labels May 8, 2024
@Bessonov
Copy link

Bessonov commented May 9, 2024

I have used Liquibase in the past, but now in a project I am migrating away from it to Kysely. While I understand the benefits of integrity checks, especially at scale, I am against them or, at least, in favor of having the option to ignore or reset the checks. I have the following reasons:

  • The integrity checks ensure only integrity between migration scripts and the metadata of scripts that have already run. If someone modifies data or the structure of data directly, you are still out of luck.
  • I assume that past scripts are modified intentionally. For example, if database vendors introduce breaking changes and migrations stop working on newer database versions in integration tests. In my current case, I want to switch to Kysely migrations by running an empty migration and then adding the entire structure from a mysqldump to this migration. Such changes can/should/must be verified in a code review anyway.
  • During development, I often modify the database structure manually (especially indexes) and then adjust the migration file accordingly. If the migration has already run, which is almost always the case, then I can't down-up to get a consistent state because the checks say no.
  • The checks introduce additional complexity to the code of Kysely.

Therefore, please do not take my reaction to the feature request personally, but as a vote.

@koskimas
Copy link
Member

koskimas commented May 9, 2024

I completely agree with @Bessonov!
We could add the check behind an option (off by default) but that would be tricky since we'd have to migrate the migration tables. I don't think there's a way to do that in a way that'd work on all possible dialects (internal and 3rd party). We'd have to add that to the dialects, making them more complex.

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

No branches or pull requests

5 participants