Migrations - Using DBMate #15
Replies: 3 comments 2 replies
-
Thanks so much for taking the time to do this write up @SteveChurch, this is awesome and I'm sure the rest of the community will find great use for it. |
Beta Was this translation helpful? Give feedback.
-
@SteveChurch just going over this again (as just got off holiday) and I've got a few questions/comments:
But again thanks for the write up, this is great 😄 |
Beta Was this translation helpful? Give feedback.
-
Hold up a second here. https://supabase.com/docs/reference/cli/supabase-db-push I thought this ( |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The Problem
Supabase don't really offer a good solution for handling migrations for those of us who want to self-host. So, the below solution overcomes this using dbmate
The solution
I have a working concept for handling migrations within Supabase Self Hosted if anyone is interested I can create an MR.
I decided to go with
dbmate
which runs within a cron on the Droplet. This triggers are scriptmigrate.sh
which runs through all of the migration files.files/migrate.sh.tftpl
locals.tf
files/migrate.cron
droplet.tf
What is great about this solution is you can take the migration files from your local dev Supabase, which have been generated by the
supabase-cli
and push them straight into Terraform. The draw back now however is that the lifecycle on the Droplet has been changed to make sureuser_data
changes always re-create.My next steps will be to set up some sort of Blue/Green deployments as the downtime with this solution sits at around 10 minutes.
@timothymamo shall I place this within an MR as I feel like migrations are a base requirement for using Supabase?
Gotchas
I use a symbilic link between the generated migration files from the
supabase-cli
and myterraform/files
so that I do not need to copy anything over. If anyone know of a way of lettingterraform
access files outside of it;s base path it woudl be good to know so that I no longer need to do this. My project structure is like this:Beta Was this translation helpful? Give feedback.
All reactions