Problem Description:
Currently, the goose package does not handle interleaved migration files effectively when developers work concurrently on different migrations. This causes issues when a developer attempts to apply migrations that were created in between existing ones, resulting in missing migration errors.
Steps to Reproduce:
Developer A adds migration files for user and admin tables, which are merged and applied in production.
Meanwhile, Developer B creates a migration for the roles table and alters the user table, with their changes existing between Developer A's migrations.
When Developer B attempts to apply their migrations using goose up, they encounter an error indicating missing migrations before the current version, despite the necessary migration files existing.
For exa-
> goose -dir db/migrations postgres "postgresql://postgres:postgres@127.0.0.1:5432/go-migartion?sslmode=disable" up
2024/07/15 18:13:28 goose run: error: found 2 missing migrations before current version 20240715084701:
version 20240715084646: db/migrations/20240715084646_new_roles_table.sql
version 20240715084655: db/migrations/20240715084655_alter_table_users.sql
Expected Behavior:
Migrations should be applied based on their logical dependency order rather than solely relying on the timestamp or version number.
The goose package should support handling interleaved migrations effectively, allowing developers to apply migrations created in between existing ones without encountering missing migration errors.
Proposed Solution:
Implement dependency tracking between migration files to determine the order of execution based on schema dependencies rather than timestamp or version number.
Additional Context:
This issue is critical for teams working concurrently on database schema changes, where multiple developers may create migrations that are interleaved in the timeline.
Enhancing migration handling will improve developer productivity and reduce errors related to applying migrations out of order.
Problem Description: Currently, the goose package does not handle interleaved migration files effectively when developers work concurrently on different migrations. This causes issues when a developer attempts to apply migrations that were created in between existing ones, resulting in missing migration errors.
Steps to Reproduce:
For exa-![migration](https://github.com/user-attachments/assets/ffed6b86-3d00-4986-82fc-123a99c7374a)
Expected Behavior:
Proposed Solution:
Additional Context: