umami
umami copied to clipboard
Error Deploying Vercel + Supabase instance
Hello! I followed the instructions to deploy umami on Vercel with the database hosted on Supase. I created a Supabase project, pasted the sql/schema.postgresql.sql into the Supabase SQL editor to create the tables, and added the DATABASE_URL (with &pgbouncer=true) and HASH_SALT env variables.
However, I got this error:
[16:27:16.430] Cloning github.com/.../umami2 (Branch: main, Commit: d09baa3)
[16:27:16.961] Cloning completed: 531.124ms
[16:27:17.491] Looking up build cache...
[16:27:17.786] Build Cache not found
[16:27:17.839] Running "vercel build"
[16:27:18.511] Vercel CLI 28.2.5
[16:27:18.962] Installing dependencies...
[16:27:19.401] yarn install v1.22.17
[16:27:19.513] [1/4] Resolving packages...
[16:27:20.009] [2/4] Fetching packages...
[16:27:51.845] [3/4] Linking dependencies...
[16:27:51.849] warning " > [email protected]" has incorrect peer dependency "react@^18.2.0".
[16:27:51.850] warning " > [email protected]" has incorrect peer dependency "react-dom@^18.2.0".
[16:27:51.851] warning "react-spring > @react-spring/[email protected]" has unmet peer dependency "konva@>=2.6".
[16:27:51.852] warning "react-spring > @react-spring/[email protected]" has unmet peer dependency "react-konva@^16.8.0 || ^17.0.0".
[16:27:51.852] warning "react-spring > @react-spring/[email protected]" has unmet peer dependency "react-native@>=0.58".
[16:27:51.852] warning "react-spring > @react-spring/[email protected]" has unmet peer dependency "@react-three/fiber@>=6.0".
[16:27:51.852] warning "react-spring > @react-spring/[email protected]" has unmet peer dependency "three@>=0.126".
[16:27:51.853] warning "react-spring > @react-spring/[email protected]" has unmet peer dependency "react-zdog@>=1.0".
[16:27:51.853] warning "react-spring > @react-spring/[email protected]" has unmet peer dependency "zdog@>=1.0".
[16:27:51.866] warning "eslint-config-next > @typescript-eslint/parser > @typescript-eslint/typescript-estree > [email protected]" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
[16:28:08.675] [4/4] Building fresh packages...
[16:28:16.742] $ prisma generate || true
[16:28:19.692] prisma:warn The postinstall script automatically ran `prisma generate` and did not find your `prisma/schema.prisma`.
[16:28:19.693] If you have a Prisma schema file in a custom path, you will need to run
[16:28:19.693] `prisma generate --schema=./path/to/your/schema.prisma` to generate Prisma Client.
[16:28:19.693] If you do not have a Prisma schema file yet, you can ignore this message.
[16:28:19.695]
[16:28:20.751] $ node -e "if (process.env.NODE_ENV !== 'production'){process.exit(1)} " || husky install
[16:28:20.904] husky - Git hooks installed
[16:28:20.913] Done in 61.52s.
[16:28:20.951] Detected Next.js version: 12.2.5
[16:28:20.953] Running "yarn run build"
[16:28:21.289] yarn run v1.22.17
[16:28:21.356] $ npm-run-all build-db check-db build-tracker build-geo build-app
[16:28:21.942] $ npm-run-all copy-db-files build-db-client
[16:28:22.512] $ node scripts/copy-db-files.js
[16:28:22.662] Database type detected: postgresql
[16:28:22.676] Copied /vercel/path0/db/postgresql to /vercel/path0/prisma
[16:28:23.120] $ prisma generate
[16:28:25.500] Prisma schema loaded from prisma/schema.prisma
[16:28:27.107]
[16:28:27.107] ✔ Generated Prisma Client (4.3.1 | library) to ./node_modules/@prisma/client in 227ms
[16:28:27.108] You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client
[16:28:27.108] ```
[16:28:27.108] import { PrismaClient } from '@prisma/client'
[16:28:27.108] const prisma = new PrismaClient()
[16:28:27.108] ```
[16:28:27.772] $ node scripts/check-db.js
[16:28:27.950] ✓ DATABASE_URL is defined.
[16:28:28.174] ✗ Unable to connect to the database.
[16:28:28.194] error Command failed with exit code 1.
[16:28:28.194] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[16:28:28.215] ERROR: "check-db" exited with 1.
[16:28:28.234] error Command failed with exit code 1.
[16:28:28.234] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[16:28:28.250] Error: Command "yarn run build" exited with 1
The error says ✗ Unable to connect to the database. Make sure you can connect manually and that your password doesn't have characters that need to be escaped.
@mikecao I think it could make debugging more easier if you can print the catched error here: https://github.com/umami-software/umami/blob/0cb14f3f6c4fd542da0f20ae55849f88ce357d6d/scripts/check-db.js#L35-L36
Thank you for your help. I solved the issues with the database connection, but now I'm having migration issues. See the error text below:
[15:26:51.027] Cloning github.com/.../umami (Branch: main, Commit: 9bcb0eb)
[15:26:51.438] Cloning completed: 410.844ms
[15:26:51.891] Looking up build cache...
[15:26:52.182] Build Cache not found
[15:26:52.221] Running "vercel build"
[15:26:52.711] Vercel CLI 28.2.5
[15:26:53.033] Installing dependencies...
[15:26:53.370] yarn install v1.22.17
[15:26:53.449] [1/4] Resolving packages...
[15:26:53.765] [2/4] Fetching packages...
[15:27:11.871] [3/4] Linking dependencies...
[15:27:11.873] warning " > [email protected]" has incorrect peer dependency "react@^18.2.0".
[15:27:11.874] warning " > [email protected]" has incorrect peer dependency "react-dom@^18.2.0".
[15:27:11.875] warning "react-spring > @react-spring/[email protected]" has unmet peer dependency "konva@>=2.6".
[15:27:11.875] warning "react-spring > @react-spring/[email protected]" has unmet peer dependency "react-konva@^16.8.0 || ^17.0.0".
[15:27:11.875] warning "react-spring > @react-spring/[email protected]" has unmet peer dependency "react-native@>=0.58".
[15:27:11.875] warning "react-spring > @react-spring/[email protected]" has unmet peer dependency "@react-three/fiber@>=6.0".
[15:27:11.875] warning "react-spring > @react-spring/[email protected]" has unmet peer dependency "three@>=0.126".
[15:27:11.875] warning "react-spring > @react-spring/[email protected]" has unmet peer dependency "react-zdog@>=1.0".
[15:27:11.875] warning "react-spring > @react-spring/[email protected]" has unmet peer dependency "zdog@>=1.0".
[15:27:11.882] warning "eslint-config-next > @typescript-eslint/parser > @typescript-eslint/typescript-estree > [email protected]" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
[15:27:33.434] [4/4] Building fresh packages...
[15:27:39.317] $ prisma generate || true
[15:27:41.641] prisma:warn The postinstall script automatically ran `prisma generate` and did not find your `prisma/schema.prisma`.
[15:27:41.641] If you have a Prisma schema file in a custom path, you will need to run
[15:27:41.641] `prisma generate --schema=./path/to/your/schema.prisma` to generate Prisma Client.
[15:27:41.642] If you do not have a Prisma schema file yet, you can ignore this message.
[15:27:41.643]
[15:27:42.443] $ node -e "if (process.env.NODE_ENV !== 'production'){process.exit(1)} " || husky install
[15:27:42.549] husky - Git hooks installed
[15:27:42.552] Done in 49.19s.
[15:27:42.585] Detected Next.js version: 12.2.5
[15:27:42.586] Running "yarn run build"
[15:27:42.848] yarn run v1.22.17
[15:27:42.891] $ npm-run-all build-db check-db build-tracker build-geo build-app
[15:27:43.324] $ npm-run-all copy-db-files build-db-client
[15:27:43.751] $ node scripts/copy-db-files.js
[15:27:43.882] Database type detected: postgresql
[15:27:43.891] Copied /vercel/path0/db/postgresql to /vercel/path0/prisma
[15:27:44.230] $ prisma generate
[15:27:46.139] Prisma schema loaded from prisma/schema.prisma
[15:27:47.504]
[15:27:47.504] ✔ Generated Prisma Client (4.3.1 | library) to ./node_modules/@prisma/client in 210ms
[15:27:47.504] You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client
[15:27:47.504] ```
[15:27:47.504] import { PrismaClient } from '@prisma/client'
[15:27:47.505] const prisma = new PrismaClient()
[15:27:47.505] ```
[15:27:48.015] $ node scripts/check-db.js
[15:27:48.148] ✓ DATABASE_URL is defined.
[15:27:48.374] ✓ Database connection successful.
[15:27:48.605] ✓ Database tables found.
[15:27:51.075] Prisma schema loaded from prisma/schema.prisma
[15:27:51.075] Datasource "db": PostgreSQL database "postgres", schema "public" at "db.nqjaxdvhlyauafxqebmm.supabase.co:6543"
[15:27:51.075]
[15:27:51.075] 3 migrations found in prisma/migrations
[15:27:51.075]
[15:27:51.075] Following migrations have not yet been applied:
[15:27:51.075] 01_init
[15:27:51.075] 02_add_event_data
[15:27:51.076] 03_remove_casade_delete
[15:27:51.076]
[15:27:51.076] To apply migrations in development run yarn prisma migrate dev.
[15:27:51.076] To apply migrations in production run yarn prisma migrate deploy.
[15:27:51.076]
[15:27:51.076] Running update...
[15:27:53.805] Prisma schema loaded from prisma/schema.prisma
[15:27:53.805] Datasource "db": PostgreSQL database "postgres", schema "public" at "db.nqjaxdvhlyauafxqebmm.supabase.co:6543"
[15:27:53.806] Migration 01_init marked as applied.
[15:27:53.806]
[15:27:56.725] Error: P3018
[15:27:56.725]
[15:27:56.725] 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
[15:27:56.725]
[15:27:56.725] Migration name: 02_add_event_data
[15:27:56.725]
[15:27:56.725] Database error code: 42501
[15:27:56.726]
[15:27:56.726] Database error:
[15:27:56.726] ERROR: must be owner of table event
[15:27:56.726]
[15:27:56.726] 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") }
[15:27:56.726]
[15:27:56.726]
[15:27:56.726] ✗ Command failed: prisma migrate deploy
[15:27:56.726] Error: P3018
[15:27:56.726]
[15:27:56.726] 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
[15:27:56.726]
[15:27:56.727] Migration name: 02_add_event_data
[15:27:56.727]
[15:27:56.727] Database error code: 42501
[15:27:56.727]
[15:27:56.727] Database error:
[15:27:56.727] ERROR: must be owner of table event
[15:27:56.727]
[15:27:56.727] 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") }
[15:27:56.727]
[15:27:56.727]
[15:27:56.727]
[15:27:56.742] error Command failed with exit code 1.
[15:27:56.742] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[15:27:56.756] ERROR: "check-db" exited with 1.
[15:27:56.771] error Command failed with exit code 1.
[15:27:56.771] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[15:27:56.782] Error: Command "yarn run build" exited with 1
Looks like you don't have permissions to edit tables on Supabase.
Please refer to the Prisma/Supabase troubleshooting instructions to attain permission.
https://supabase.com/docs/guides/integrations/prisma#troubleshooting
Closing for no activity. Please refer to discussion here, https://github.com/umami-software/umami/discussions/1542
Thanks for linking to https://github.com/umami-software/umami/discussions/1542! My issue has finally been resolved (now I just have to transfer my old data to my new deployment).
In case anyone has the same issue as me, here are the steps I took:
I ran both rohandebsarkar's Solution and Prisma's Solution from https://github.com/umami-software/umami/discussions/1542 in Supabase's SQL Editor.
I then ran into the error described here: https://github.com/umami-software/umami/discussions/1486#discussioncomment-3567442.
To solve this, I did the following:
- Forked the umami GitHub project
- Cloned my fork locally using GitHub Desktop
- In my local folder, I created a file called
.env. In this file, I typed inDATABASE_URL=and pasted the postgres URL from Supabase (Connection Pooling>Connection String) along with?pgbouncer=true - Once that was done, I ran the following commands in my command prompt (with the directory set to my local cloned umami fork):
yarn install
yarn build
yarn prisma migrate resolve --applied "02_add_event_data"
Once that was done, I redeployed on Vercel, and it now works.
Thank you everyone for your help!