Server: Fix migrations

pull/5309/head
Laurent Cozic 2021-08-13 21:58:39 +01:00
parent 32c8cc9030
commit f518549cfe
2 changed files with 10 additions and 6 deletions

View File

@ -6,9 +6,9 @@ export async function up(db: DbConnection): Promise<any> {
table.text('key', 'mediumtext').defaultTo('').notNullable(); table.text('key', 'mediumtext').defaultTo('').notNullable();
}); });
await db.schema.alterTable('emails', function(table: Knex.CreateTableBuilder) { // await db.schema.alterTable('emails', function(table: Knex.CreateTableBuilder) {
table.unique(['recipient_email', 'key']); // table.unique(['recipient_email', 'key']);
}); // });
} }
export async function down(_db: DbConnection): Promise<any> { export async function down(_db: DbConnection): Promise<any> {

View File

@ -2,9 +2,13 @@ import { Knex } from 'knex';
import { DbConnection } from '../db'; import { DbConnection } from '../db';
export async function up(db: DbConnection): Promise<any> { export async function up(db: DbConnection): Promise<any> {
await db.schema.alterTable('emails', function(table: Knex.CreateTableBuilder) { try {
table.dropUnique(['recipient_email', 'key']); 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<any> { export async function down(_db: DbConnection): Promise<any> {