umami: v1 to v2 migration fails on Postgres
I am running the latest v1 Umami with Postgres and wanted to update to v2.
The umami directory is /tmp/t/app.
On the first try, I got this error:
$ yarn add @umami/migrate-v1-v2
$ npx @umami/migrate-v1-v2
✓ DATABASE_URL is defined.
✓ Database connection successful.
Preparing v1 tables for migration
✓ Dropped v1 database keys.
PrismaClientKnownRequestError:
Invalid `prisma.$executeRaw()` invocation:
Raw query failed. Code: `2BP01`. Message: `db error: ERROR: cannot drop index website_share_id_key because constraint website_share_id_key on table website requires it
HINT: You can drop constraint website_share_id_key on table website instead.`
at fn.handleRequestError (/tmp/t/app/node_modules/@prisma/client/runtime/library.js:174:6477)
at fn.handleAndLogRequestError (/tmp/t/app/node_modules/@prisma/client/runtime/library.js:174:5907)
at fn.request (/tmp/t/app/node_modules/@prisma/client/runtime/library.js:174:5786)
at async Proxy._request (/tmp/t/app/node_modules/@prisma/client/runtime/library.js:177:10477) {
code: 'P2010',
clientVersion: '4.12.0',
meta: {
code: '2BP01',
message: 'db error: ERROR: cannot drop index website_share_id_key because constraint website_share_id_key on table website requires it\n' +
'HINT: You can drop constraint website_share_id_key on table website instead.'
}
}
✗ Failed to drop v1 database indexes.
After dropping the mentioned constraint manually, it now fails to find some migration sql scripts:
$ npx @umami/migrate-v1-v2
✓ DATABASE_URL is defined.
✓ Database connection successful.
Preparing v1 tables for migration
✓ Dropped v1 database keys.
✓ Dropped v1 database indexes.
✓ Renamed v1 database tables.
✓ Database v1 tables ready for migration.
Database v2 tables not found.
Adding v2 tables...
[Error: ENOENT: no such file or directory, open '/tmp/t/app/node_modules/@umami/migrate-v1-v2/prisma/migrations/01_init/migration.sql'] {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/tmp/t/app/node_modules/@umami/migrate-v1-v2/prisma/migrations/01_init/migration.sql'
}
✗ Failed to run sql file /prisma/migrations/01_init/migration.sql.
Did I miss something?
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 18 (2 by maintainers)
Fix: PR #1908
The
npxversion of the migration skips the build step (which you run as part of the standalone migration), which movesdb/postgresql/ordb/mysql/toprisma/. That’s why it’s looking in the wrong place. You can do it manually before running the migration:@dyxang Restart your supabase.
This is what my
prismafolder looks like:I ran this:
Afterwards I ran this:
That looked really good and thus I tried another deploy to Heroku. Relevant build log entry:
The deploy succeeded. I now have a working Umami install. Without any historic data, but it is running.
Update: I updated the tracking snippet code and now everything (tracking, backend, etc.) appears to work as expected. For me this issue is now closed. I hope these steps help others to get their v2 up and running.
Same error here. I was able to fix it by correcting the paths listed in line 89 & 106 of
/node_modules/@umami/migrate-v1-v2/index.jsCorrect paths: line 89:
await runSqlFile('/db/postgresql/migrations/01_init/migration.sql');line 106:
const filePath = '/db/postgresql/data-migration-v2.sql';This fixed the issue and I could complete the migration.
However, afterwards I run into this error while deploying to Heroku.
Any ideas?