Fix v1 check error showing in postgres logs

This commit is contained in:
Francis Cao 2023-09-06 11:34:12 -07:00
parent acb7fdcae8
commit 0e0788b0a1

View File

@ -66,12 +66,16 @@ async function checkDatabaseVersion() {
async function checkV1Tables() {
try {
await prisma.$queryRaw`select * from account limit 1`;
// check for v1 migrations before v2 release date
const record =
await prisma.$queryRaw`select * from _prisma_migrations where started_at < '2023-04-17'`;
error(
'Umami v1 tables detected. For how to upgrade from v1 to v2 go to https://umami.is/docs/migrate-v1-v2.',
);
process.exit(1);
if (record.length > 0) {
error(
'Umami v1 tables detected. For how to upgrade from v1 to v2 go to https://umami.is/docs/migrate-v1-v2.',
);
process.exit(1);
}
} catch (e) {
// Ignore
}