-
Notifications
You must be signed in to change notification settings - Fork 237
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
Comments
A simpler solution/workaround would be to extend |
Great suggestion! 👍 To build on it, a |
I think the main benefit of repeatable migration is to reduce code duplication. But after some initial exploration by @JohnBra, the cost involves changes to migration list and db reset commands which seem fairly complex. So taking a step back, may I suggest using declarative schemas instead? For eg. you can define views and functions in
To diff the declared schemas, remember to stop the local database first. |
I'm not sure the declarative approach is the best way to go:
If this would be integrated into other commands ( I do see the good side of it though, having one |
Shameless plug: I made https://github.com/t1mmen/srtd to simplify this exact problem. Also comes with quite a few DX benefits, like live/hot loading changes directly to DB (locally). (I only discovered the CLI supported declarative schemas today; haven't tried that yet, but srtd seems to offer better DX atm) Supabase crew, feel free to steal the good ideas from my project and bake into the CLI directly :) |
We actually supported declarative schemas almost a year ago, but haven't documented or announced it until recently. It's a bit of a shame that migra is no longer actively maintained. But the good news is there's a new diff tool open sourced by stripe. It has better support for generating zero downtime migrations. This option is also baked into Supabase CLI via Nevertheless, I'm impressed by the interest and your work done in this space. I believe the community will benefit a lot from having a perfect schema diff tool for Postgres. |
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 MigrationsLet's say we have these files in the
migrations
folderRunning
migration up
would applymigration_1
and thenmy_view_or_function
(it can usecurrent_timestamp
as version).We now add a new migration:
Running
migration up
would skipmigration_1
, applymigration_2
, and then re-applymy_view_or_function
(with a differentcurrent_timestamp
as version).Describe alternatives you've considered
Manually executing
r_my_view_or_function.sql
after applying migrations by connecting to the database directlyAdditional context
N/A
The text was updated successfully, but these errors were encountered: