Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Fix v1 check error showing in postgres logs

Francis Cao0e0788b0a1b1
diff --git a/scripts/check-db.js b/scripts/check-db.js
index a84a775ce..757843ac3 100644
--- a/scripts/check-db.js
+++ b/scripts/check-db.js
@@ -66,12 +66,16 @@ async function checkDatabaseVersion() {
async function checkV1Tables() {
try {
- await prisma.$queryRaw`select * from account limit 1`;
-
- 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);
+ // check for v1 migrations before v2 release date
+ const record =
+ await prisma.$queryRaw`select * from _prisma_migrations where started_at < '2023-04-17'`;
+
+ 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
}