From 7bc08c0425d100451fbedc0a1d71269d75093ae8 Mon Sep 17 00:00:00 2001 From: Owen Date: Wed, 6 May 2026 20:00:23 -0700 Subject: [PATCH] If not exists on trial table --- server/setup/scriptsPg/1.18.3.ts | 6 +----- server/setup/scriptsSqlite/1.18.3.ts | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/server/setup/scriptsPg/1.18.3.ts b/server/setup/scriptsPg/1.18.3.ts index bbed1ee0e..1e786fa07 100644 --- a/server/setup/scriptsPg/1.18.3.ts +++ b/server/setup/scriptsPg/1.18.3.ts @@ -44,7 +44,7 @@ export default async function migration() { await db.execute(sql`BEGIN`); await db.execute(sql` - CREATE TABLE "trialNotifications" ( + CREATE TABLE IF NOT EXISTS "trialNotifications" ( "notificationId" serial PRIMARY KEY NOT NULL, "subscriptionId" varchar(255) NOT NULL, "notificationType" varchar(50) NOT NULL, @@ -52,10 +52,6 @@ export default async function migration() { ); `); - await db.execute(sql` - ALTER TABLE "trialNotifications" ADD CONSTRAINT "trialNotifications_subscriptionId_subscriptions_subscriptionId_fk" FOREIGN KEY ("subscriptionId") REFERENCES "public"."subscriptions"("subscriptionId") ON DELETE cascade ON UPDATE no action; - `); - await db.execute(sql`COMMIT`); console.log("Migrated database"); } catch (e) { diff --git a/server/setup/scriptsSqlite/1.18.3.ts b/server/setup/scriptsSqlite/1.18.3.ts index ad82327fe..74f9b5344 100644 --- a/server/setup/scriptsSqlite/1.18.3.ts +++ b/server/setup/scriptsSqlite/1.18.3.ts @@ -16,7 +16,7 @@ export default async function migration() { db.transaction(() => { db.prepare( ` - CREATE TABLE 'trialNotifications' ( + CREATE TABLE IF NOT EXISTS 'trialNotifications' ( 'notificationId' integer PRIMARY KEY AUTOINCREMENT NOT NULL, 'subscriptionId' text NOT NULL, 'notificationType' text NOT NULL,