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

Add automatic database migrations #62

Open
carlomigueldy opened this issue Nov 19, 2021 · 4 comments
Open

Add automatic database migrations #62

carlomigueldy opened this issue Nov 19, 2021 · 4 comments
Assignees
Labels
ci 🗃 database Database design, schema, queries, row level security, etc

Comments

@carlomigueldy
Copy link
Contributor

carlomigueldy commented Nov 19, 2021

Overview

I haven't read abour this in context of supabase but the idea is setting up a CI step that will update the database schema when we roll out updates to production. This so we don't have the pressure of manually running a script to keep the schema in sync. When I look for supabase migrations I ended up at their cli https://supabase.com/blog/2021/03/31/supabase-cli

From @JoviDeCroock


Migrations are like version control for your database, allowing your team to define and share the application's database schema definition. If you have ever had to tell a teammate to manually add a column to their local database schema after pulling in your changes from source control, you've faced the problem that database migrations solve. (Read more here)

I have worked with Laravel projects in the past and it's where I got introduced to database migrations, it was fairly easy to use it with just a few artisan commands to run e.g. php artisan make:migration update_users_table, php artisan migrate

PS: Thought I'd create an issue for this after you sent me a DM about it @JoviDeCroock

How it works

The current process of updating database tables, modifying columns, adding attributes to columns, etc is to manually run SQL statements inside Supabase or PostgreSQL client (e.g. PGAdmin). With that process we can't really keep track of when the attributes were modified into the tables or forget to run the SQL statements.

Typically how database migrations would work:

  • Create a migration file with the current timestamp as its filename at the time it was created
  • Inside the migration file, have a SQL statement that modifies the database (e.g. ALTER COLUMN ...)
  • Run a terminal command to finally execute these migrations into the database (e.g. php artisan migrate)

Migrations are usually be generated from CLI tools.

References

There is an active pull request by @G3root here where it uses Prisma

@carlomigueldy carlomigueldy added 🗃 database Database design, schema, queries, row level security, etc ci labels Nov 19, 2021
@with-heart
Copy link
Member

Could you please explain what "automatic database migrations" refers to here?

How do they work? What might we need to do to make them happen?

Is there a documentation page that might provide more context?

@JoviDeCroock
Copy link
Contributor

I haven't read abour this in context of supabase but the idea is setting up a CI step that will update the database schema when we roll out updates to production. This so we don't have the pressure of manually running a script to keep the schema in sync. When I look for supabase migrations I ended up at their cli https://supabase.com/blog/2021/03/31/supabase-cli

@carlomigueldy
Copy link
Contributor Author

Could you please explain what "automatic database migrations" refers to here?
How do they work? What might we need to do to make them happen?
Is there a documentation page that might provide more context?

Updated the description for this ticket to address these.

@carlomigueldy
Copy link
Contributor Author

carlomigueldy commented Nov 19, 2021

Just a question since I didn't completely catch it from Discord conversation I was a bit lost with a bunch of options thrown out, why would we defer from using Prisma? @JoviDeCroock

  1. What's the concern main concerns of it on using it client side?
  2. What's the concern main concerns of it on using it server side? (e.g. Serverless Functions)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci 🗃 database Database design, schema, queries, row level security, etc
Projects
None yet
Development

No branches or pull requests

3 participants