umami
umami copied to clipboard
Prisma migrate failing on Vercel + Supabase
I am getting the following error while deploying to Vercel using Supabase.
[22:17:26.654] Cloning completed: 682.504ms
[22:17:27.082] Looking up build cache...
[22:17:27.530] Build Cache not found
[22:17:27.568] Running "vercel build"
[22:17:28.071] Vercel CLI 28.2.5
[22:17:28.393] Installing dependencies...
[22:17:28.739] yarn install v1.22.17
[22:17:28.825] [1/4] Resolving packages...
[22:17:29.142] [2/4] Fetching packages...
[22:17:49.356] [3/4] Linking dependencies...
[22:17:49.359] warning " > [email protected]" has incorrect peer dependency "react@^18.2.0".
[22:17:49.359] warning " > [email protected]" has incorrect peer dependency "react-dom@^18.2.0".
[22:17:49.360] warning "react-spring > @react-spring/[email protected]" has unmet peer dependency "konva@>=2.6".
[22:17:49.360] warning "react-spring > @react-spring/[email protected]" has unmet peer dependency "react-konva@^16.8.0 || ^17.0.0".
[22:17:49.360] warning "react-spring > @react-spring/[email protected]" has unmet peer dependency "react-native@>=0.58".
[22:17:49.361] warning "react-spring > @react-spring/[email protected]" has unmet peer dependency "@react-three/fiber@>=6.0".
[22:17:49.361] warning "react-spring > @react-spring/[email protected]" has unmet peer dependency "three@>=0.126".
[22:17:49.361] warning "react-spring > @react-spring/[email protected]" has unmet peer dependency "react-zdog@>=1.0".
[22:17:49.361] warning "react-spring > @react-spring/[email protected]" has unmet peer dependency "zdog@>=1.0".
[22:17:49.367] 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".
[22:18:08.703] [4/4] Building fresh packages...
[22:18:15.383] $ prisma generate || true
[22:18:17.745] prisma:warn The postinstall script automatically ran `prisma generate` and did not find your `prisma/schema.prisma`.
[22:18:17.745] If you have a Prisma schema file in a custom path, you will need to run
[22:18:17.745] `prisma generate --schema=./path/to/your/schema.prisma` to generate Prisma Client.
[22:18:17.745] If you do not have a Prisma schema file yet, you can ignore this message.
[22:18:17.745]
[22:18:18.558] $ node -e "if (process.env.NODE_ENV !== 'production'){process.exit(1)} " || husky install
[22:18:18.701] husky - Git hooks installed
[22:18:18.704] Done in 49.97s.
[22:18:18.741] Detected Next.js version: 12.2.5
[22:18:18.743] Running "yarn run build"
[22:18:19.012] yarn run v1.22.17
[22:18:19.055] $ npm-run-all build-db check-db build-tracker build-geo build-app
[22:18:19.495] $ npm-run-all copy-db-files build-db-client
[22:18:19.932] $ node scripts/copy-db-files.js
[22:18:20.068] Database type detected: postgresql
[22:18:20.077] Copied /vercel/path0/db/postgresql to /vercel/path0/prisma
[22:18:20.425] $ prisma generate
[22:18:22.351] Prisma schema loaded from prisma/schema.prisma
[22:18:23.733]
[22:18:23.733] ✔ Generated Prisma Client (4.3.1 | library) to ./node_modules/@prisma/client in 213ms
[22:18:23.733] You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client
[22:18:23.734] ```
[22:18:23.734] import { PrismaClient } from '@prisma/client'
[22:18:23.734] const prisma = new PrismaClient()
[22:18:23.734] ```
[22:18:24.246] $ node scripts/check-db.js
[22:18:24.384] ✓ DATABASE_URL is defined.
[22:18:24.601] ✓ Database connection successful.
[22:18:24.804] ✓ Database tables found.
[22:18:27.285] Prisma schema loaded from prisma/schema.prisma
[22:18:27.285] Datasource "db": PostgreSQL database "postgres", schema "public" at "db.mjgxuaynzfgwuhjrndcw.supabase.co:6543"
[22:18:27.285]
[22:18:27.285] 3 migrations found in prisma/migrations
[22:18:27.285]
[22:18:27.286] Following migration have not yet been applied:
[22:18:27.286] 03_remove_casade_delete
[22:18:27.286]
[22:18:27.286] To apply migrations in development run yarn prisma migrate dev.
[22:18:27.286] To apply migrations in production run yarn prisma migrate deploy.
[22:18:27.286]
[22:18:27.286] Running update...
[22:18:30.043] Error: P3009
[22:18:30.043]
[22:18:30.044] migrate found failed migrations in the target database, new migrations will not be applied. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve
[22:18:30.044] The `02_add_event_data` migration started at 2022-09-17 16:44:24.033587 UTC failed
[22:18:30.044]
[22:18:30.044]
[22:18:30.044] ✗ Command failed: prisma migrate deploy
[22:18:30.044] Error: P3009
[22:18:30.044]
[22:18:30.044] migrate found failed migrations in the target database, new migrations will not be applied. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve
[22:18:30.045] The `02_add_event_data` migration started at 2022-09-17 16:44:24.033587 UTC failed
[22:18:30.045]
[22:18:30.045]
[22:18:30.045]
[22:18:30.060] error Command failed with exit code 1.
[22:18:30.061] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[22:18:30.075] ERROR: "check-db" exited with 1.
[22:18:30.091] error Command failed with exit code 1.
[22:18:30.091] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[22:18:30.101] Error: Command "yarn run build" exited with 1
Please suggest.
Looks like your 02_migration failed. You'll likely have to roll back and re-run it. Please refer to this thread for your situation.
https://github.com/umami-software/umami/discussions/1434#discussion-4307103
Tried using the commands. Getting this error now.
3 migrations found in prisma/migrations
Applying migration `02_add_event_data`
Error: P3018
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
Migration name: 02_add_event_data
Database error code: 42501
Database error:
ERROR: must be owner of table event
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") }
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: "update-db" exited with 1.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Command "yarn run build" exited with 1
I even tried with a fresh install/database and it failed again with the same error.
It looks like there's an issue w/ supabase not assigning table edit permissions to the login.
Please refer to the Prisma/Supabase instructions to attain permission.
https://supabase.com/docs/guides/integrations/prisma#troubleshooting