-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Context
Right now, migrations can be created once, be applied, and there is nothing that prevents that migration to be modified accidentally by the user, ending up doing no effect because the migration has already been recorded as applied.
Requirements
Come up with something that prevents applied migrations from being changed after they have been applied.
Below is an overview of my initial idea:
- Track the every executed SQL command during a migration, combine it, hash, and store the hash
- If the hash ever changes, that means the migration has been modified
- Add a new function in the
migrationspackage, likemigrations.EnsureImmutabilityormigrations.ValidateAppliedMigrations, that:- Runs every applied migration again using an alternative SQLExecutor implementation that doesn't actually execute the script, only tracks the commands
- For each migration, combine the commands and hash it (same process of when it's actually executed)
- Compare the produced hash with the recorded hash
- Return a list of errors (migrations that have been applied and had their hash was changed)
- Let the user can decide what to do with the errors (such as panic the program startup)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request