Does anyone know what is the correct way to migrat...
# sql
y
Does anyone know what is the correct way to migrate to production databases?
c
can you be a little more specific? Maybe provide an example or the details of your use case
y
I have a file 'schema.sql' with the definition of all tables, functions, RSL policies, etc. So far, as my tables changed, I have been modifying manually through the GUI to Supabase, however, this can be dangerous and I like to automate it, but I do not know how to do it correctly
c
Ok, just to make sure we are on the same page - you need a way to automate the process of syncing the db schema changes in a dev environment to your prod environemtn, correct?
y
That is, I have tried what they explain in this post, but it does not work, the generated script does some crazy things, such as it makes use of relationships, tables or limitations before even defining it, and of course, the resulting script does not work. https://supabase.io/blog/2021/03/31/supabase-cli#migrations
s
You can use a migration library, I'm working on a course at the moment that will teach about doing this. Also recently @User wrote a really good article around this https://www.slip.so/tutorials/database-migrations-in-supabase-with-migra
Also there is this guide from the Supabase team https://supabase.io/docs/guides/database#migrating-between-projects
y
Thanks for sharing, I'll try. I had ruled out "migra" because of what it said in the article (which was second on the list), but at the moment it seems like the solution, thanks!