vercel / nextjs-subscription-payments

Clone, deploy, and fully customize a SaaS subscription application with Next.js.
https://subscription-payments.vercel.app/
MIT License
6.08k stars 1.23k forks source link

generated tables are owned by supabase_admin and therefore not editable #172

Closed thosmos closed 1 year ago

thosmos commented 1 year ago

When I generated a Supabase project using Vercel's automated deployment, and then attempted to make any changes to the tables or policies created by this integration, I got an error about not being the owner. I tried running the deployment a second time and got the same result.

Screen Shot 2023-03-18 at 9 49 04 AM

It looks like the problem is that the tables are owned by the supabase_admin user instead of postgres which is the new current default. Here's an example showing the ownership of the tables as contrasted with the dashtest table that was created using Supabase's dashboard:

postgres=> \dt
                List of relations
 Schema |     Name      | Type  |     Owner      
--------+---------------+-------+----------------
 public | customers     | table | supabase_admin
 public | dashtest      | table | postgres
 public | prices        | table | supabase_admin
 public | products      | table | supabase_admin
 public | subscriptions | table | supabase_admin
 public | users         | table | supabase_admin
(6 rows)

I created a new Supabase project and ran the schema.sql file directly in the dashboard SQL Editor and the tables were owned by postgres:

postgres=> \dt
             List of relations
 Schema |     Name      | Type  |  Owner   
--------+---------------+-------+----------
 public | customers     | table | postgres
 public | prices        | table | postgres
 public | products      | table | postgres
 public | subscriptions | table | postgres
 public | users         | table | postgres
(5 rows)

So this appears to be a problem with how the schema.sql file is run when doing the automated deployment.

btahir commented 1 year ago

Just ran into this issue :(

Wth - was working fine before. Any magic SQL we can run in the console to fix this?

devalsysoft commented 1 year ago

Alter table public.[YOUR TABLE NAME GOES IN HERE] owner to postgres;

btahir commented 1 year ago

I tried...didn't work. Ended up just creating a new table.

devalsysoft commented 1 year ago

Or connect with dbeaver or pgAdmin and edit owners.

thorwebdev commented 1 year ago

Thanks for reporting this, we're currently looking into it.

thorwebdev commented 1 year ago

This has now been fixed. Unfortunately you will need to start over to get this set up correctly, sorry about that!

jinalex commented 1 year ago

Deployed a new project over the weekend and all my tables are still owned by supabase_admin btw

fabianuribe commented 1 year ago

+1 . supabase_admin is still the owner of the tables for my project launched on Mar 30, 2023 (after the bug was closed)

cc/ @thorwebdev

louis030195 commented 1 year ago

same - cloned few day ago

any quick solution for this? supabase support is not useful atm

ps: didnt even manage to fix with psql :(

thorwebdev commented 1 year ago

Reopening and investigating, thanks for reporting!

thorwebdev commented 1 year ago

Sorry about this, there was a regression in our Vercel Deploy integration that changed the role of the setup SQL. This has now been fixed again and should work as expected for new installations.