Hi Supabasers (is that what we call ourselves?), ...
# off-topic
s
Hi Supabasers (is that what we call ourselves?), I just joined this discord. I am exploring Supabase as a possible solution for my company. I have a few questions related to the idea of eliminating the "backend" as implied by many docs (example: https://postgrest.org/en/v8.0/) related to Supabase. To be honest, I like that. The less code we write the better. But to be honest, I am debating with myself on whether this is possible or not. Here are my concerns: 1. How are Schema migrations expected to be handled? Usually, we have backend code that on boot runs migration scripts against the DB. Since the backend code is bundled with the migration scripts we can make sure they never deviate. Without a backend how do you manage that? You simply have git repo with SQL scripts? 2. Since we have no backend, that means we need to write complex queries. Is the Javascript query dsl, provided by supabase, able handle complex queries (multiple joins, subqueries, summation of columns, etc..)? Or are we expected to create postgress functions to encapsulate complex queries? 3. Basically, what is your workflow? Thanks!
s
1. Not sure how others do this without backend code, but I use a migration tool like
ley
(which would be considered backend since it runs in node) to handle migrations between projects. You can do this because you have direct access to the Postgres database that Supabase hosts for you 2. For complex queries I handle these inside the database, either by using views or functions. This also makes it one source of truth and these can also be created with the migration tool too since they are just plain SQL most of the times. 3. My workflow is what I stated above.
s
Great, thanks for the reply. Follow up, question: Lets say u want to write then read the same data. This should be ideally done within the same transaction due to database isolation issues. Can u create a transaction that contains a UPDATE then SELECT query using Supabase qeries? All backend framework allow for this.
s
You can definitely do that in a function, also on insert or update with standard Supabase queries you get the result returned.