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

Support for repeatable migrations #2784

Open
salah3x opened this issue Oct 20, 2024 · 2 comments
Open

Support for repeatable migrations #2784

salah3x opened this issue Oct 20, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@salah3x
Copy link

salah3x commented Oct 20, 2024

Is your feature request related to a problem? Please describe.
When updating definitions for objects such as views or functions, a new migration is required, which means we have to duplicate the definition to add the necessary modification.

Describe the solution you'd like
Have some repeatable migrations that are applied with each migration up command, something similar to Flyway's Repeatable Migrations

Let's say we have these files in the migrations folder

[timestamp1]_migration_1.sql
r_my_view_or_function.sql

Running migration up would apply migration_1 and then my_view_or_function (it can use current_timestamp as version).
We now add a new migration:

[timestamp1]_migration_1.sql
[timestamp2]_migration_2.sql
r_my_view_or_function.sql

Running migration up would skip migration_1, apply migration_2, and then re-apply my_view_or_function (with a different current_timestamp as version).

Describe alternatives you've considered
Manually executing r_my_view_or_function.sql after applying migrations by connecting to the database directly

Additional context
N/A

@sweatybridge sweatybridge added the enhancement New feature or request label Oct 23, 2024
@salah3x
Copy link
Author

salah3x commented Oct 25, 2024

A simpler solution/workaround would be to extend migrations up to always execute some SQL file (if present) in the migrations directory (matching a filename or a prefix), similar to seed.sql and the start or db reset commands

@KadarH
Copy link

KadarH commented Oct 26, 2024

Great suggestion! 👍 To build on it, a post-migration hook for auto-running r_ files after migration up could keep the definitions updated without duplicating. This would streamline updates to views/functions and keep migrations cleaner!

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

No branches or pull requests

3 participants