News for hackers. Stuff that matters.
Re:Declarative Schemas for simpler database management by rjbwork on Thursday April 03, 2025 @03:19PM (#43574138)
>If you're clever you add a manual review stage in the pipeline and have the db engineers approve the generated migration script before deployment is completed automatically.

This is how I've set it up at my current employer. It works well. We modeled it after the Terraform Plan/Apply steps, and double check that the script generated by the "apply" step matches the script generated by the "plan" step, since these can occur at significant temporal distances, and fail it if not, just so that we can be sure what we've read and approved matches what gets executed.

Re:Declarative Schemas for simpler database management by kiwicopple on Thursday April 03, 2025 @03:42PM (#43574427)
> db engineers approve the generated migration script

yeah - this is definitely the intended flow here. We won't be recommending anyone blindly applying generated migrations.

As you mention, it is expected that you generate & review on your local development machine, check into source control, push & merge. We've also been using this internally for ~2 years now and it works great

Re:Declarative Schemas for simpler database management by pounderstanding on Thursday April 03, 2025 @04:32PM (#43575006)
Do you keep the history of applied migrations? (Just in case subtle issue need to be investigated later)
Re:Declarative Schemas for simpler database management by kiwicopple on Thursday April 03, 2025 @04:37PM (#43575070)
yeah, migrations are generated from the Declarative files. For example, the steps are for adding a new column:

1/ Add a new column to the declarative file

2/ Generate a new migration: `supabase db diff -f my_new_migration`

3/ Review/edit the generated migration, check it into git

4/ Apply migration to database