From f518549cfe85d99b0ad544e624e82bdc2b30f89b Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Fri, 13 Aug 2021 21:58:39 +0100 Subject: [PATCH] Server: Fix migrations --- .../server/src/migrations/20210809163307_email_key.ts | 6 +++--- .../src/migrations/20210809222118_email_key_fix.ts | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/server/src/migrations/20210809163307_email_key.ts b/packages/server/src/migrations/20210809163307_email_key.ts index ba868f4e9..971fd3718 100644 --- a/packages/server/src/migrations/20210809163307_email_key.ts +++ b/packages/server/src/migrations/20210809163307_email_key.ts @@ -6,9 +6,9 @@ export async function up(db: DbConnection): Promise { table.text('key', 'mediumtext').defaultTo('').notNullable(); }); - await db.schema.alterTable('emails', function(table: Knex.CreateTableBuilder) { - table.unique(['recipient_email', 'key']); - }); + // await db.schema.alterTable('emails', function(table: Knex.CreateTableBuilder) { + // table.unique(['recipient_email', 'key']); + // }); } export async function down(_db: DbConnection): Promise { diff --git a/packages/server/src/migrations/20210809222118_email_key_fix.ts b/packages/server/src/migrations/20210809222118_email_key_fix.ts index 5dff801fb..2ca9d10d7 100644 --- a/packages/server/src/migrations/20210809222118_email_key_fix.ts +++ b/packages/server/src/migrations/20210809222118_email_key_fix.ts @@ -2,9 +2,13 @@ import { Knex } from 'knex'; import { DbConnection } from '../db'; export async function up(db: DbConnection): Promise { - await db.schema.alterTable('emails', function(table: Knex.CreateTableBuilder) { - table.dropUnique(['recipient_email', 'key']); - }); + try { + await db.schema.alterTable('emails', function(table: Knex.CreateTableBuilder) { + table.dropUnique(['recipient_email', 'key']); + }); + } catch (error) { + console.warn('Could not drop unique constraint - this is not an error.', error); + } } export async function down(_db: DbConnection): Promise {