umami icon indicating copy to clipboard operation
umami copied to clipboard

Failed Netlify + Supabase

Open azat-io opened this issue 1 year ago • 10 comments

Steps to reproduce:

  1. Open Supabase

  2. Create database

  3. Open Settings / Database / Connection Pooling

  4. Copy Connection string, replace [YOUR-PASSWORD] with password, add ?pgbouncer=true to string

  5. Open SQL editor, paste code from here and click RUN

  6. Open Netlify

  7. Connect forked repo with project

  8. Open Site settings / Build & deploy / Enviorenment

  9. Add variables HASH_SALT with random string and DATABASE_URL with our updated connection string

  10. Open Deploys, click Trigger deploy

After these steps I get the following error:

9:12:48 PM: Error: P3018
9:12:48 PM: 
9:12:48 PM: A migration failed to apply. New migrations cannot be applied before the error is recovered from. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve
9:12:48 PM: 
9:12:48 PM: Migration name: 02_add_event_data
9:12:48 PM: 
9:12:48 PM: Database error code: 42501
9:12:48 PM: 
9:12:48 PM: Database error:
9:12:48 PM: ERROR: must be owner of table event
9:12:48 PM: 
9:12:48 PM: DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E42501), message: "must be owner of table event", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("aclchk.c"), line: Some(3583), routine: Some("aclcheck_error") }
9:12:48 PM: 
9:12:48 PM: ✗ Command failed: prisma migrate deploy
9:12:48 PM: Error: P3018
9:12:48 PM: 
9:12:48 PM: A migration failed to apply. New migrations cannot be applied before the error is recovered from. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve
9:12:48 PM: 
9:12:48 PM: Migration name: 02_add_event_data
9:12:48 PM: 
9:12:48 PM: Database error code: 42501
9:12:48 PM: 
9:12:48 PM: Database error:
9:12:48 PM: ERROR: must be owner of table event
9:12:48 PM: 
9:12:48 PM: DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E42501), message: "must be owner of table event", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("aclchk.c"), line: Some(3583), routine: Some("aclcheck_error") }
9:12:48 PM: 
9:12:48 PM: 
9:12:48 PM: 
9:12:48 PM: error Command failed with exit code 1. (https://ntl.fyi/exit-code-1)
9:12:48 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
9:12:48 PM: ERROR: "check-db" exited with 1.
9:12:48 PM: error Command failed with exit code 1. (https://ntl.fyi/exit-code-1)
9:12:48 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

azat-io avatar Sep 16 '22 18:09 azat-io

Seems to be on your database configuration side. I use Netlify with a postgresql database on heroku, I have no error (just deployed few minutes ago with the latest version of umami).

Ok you got this error. But what did you try to do to fix it?

duboiss avatar Sep 16 '22 21:09 duboiss

It seems that I do everything according to the documentation

azat-io avatar Sep 16 '22 22:09 azat-io

Don't understand why you follow Supabase documentation if you want to use Netlify ? I just follow netlify documentation (without useless HASH_SALT environment variable) using the postgres connection string (without pgbouncer=true option) and it works well.

https://umami.is/docs/running-on-netlify

What I did :

  • Clone umami fork repository on my local
  • Created .env file with DATABASE_URL environment variable filled (hosted on supabase)
  • Run yarn build, yarn update-db even he did nothing
  • Add DATABASE_URL environment variable on netlify, deploy the site

duboiss avatar Sep 17 '22 10:09 duboiss

@duboiss Looks like deploy works without pgbouncer=true. Thanks! But sometimes on various requests I get an "Internal server error"

azat-io avatar Sep 17 '22 12:09 azat-io

By various requests you mean when you navigate on the website one deployed on Netlify you have some errors ? Which page in particular ?

duboiss avatar Sep 17 '22 12:09 duboiss

Screenshot 2022-09-17 at 4 22 52 PM

@duboiss On all pages there are different requests break. It's just that everything is unstable. After refreshing the page, they may start working, or others may break.

azat-io avatar Sep 17 '22 13:09 azat-io

It looks like anytime the event table is hit, you're getting errors which makes me believe your 01 migration ran ok, but your 02 did not. Did you run any special commands to re-run your migrations after getting errors?

briancao avatar Sep 17 '22 18:09 briancao

@briancao

Did you run any special commands to re-run your migrations after getting errors?

No

azat-io avatar Sep 17 '22 20:09 azat-io

It looks like there's an issue w/ supabase not assigning table edit permissions to the login.

Please refer to Prisma/Supabase instructions to attain permission.

https://supabase.com/docs/guides/integrations/prisma#troubleshooting

briancao avatar Sep 21 '22 05:09 briancao

@briancao I used the script but nothing changed. The problem persists. If I use pgbouncer=true I get the same error in deployment. If I use clean url for DB I get 500 error

azat-io avatar Sep 21 '22 19:09 azat-io

Can you re-post the error you're getting? Migrations shouldn't run alters if the previous migration failed w/o --rollbacks or --applied.

briancao avatar Sep 21 '22 20:09 briancao

Just tried deploying and I'm getting the same error. :)

ijkml avatar Sep 22 '22 09:09 ijkml

Try following https://github.com/umami-software/umami/discussions/1486#discussioncomment-3567397.

rohandebsarkar avatar Sep 27 '22 16:09 rohandebsarkar

@rohandebsarkar It works! Thank you!

azat-io avatar Sep 28 '22 18:09 azat-io