Code creep: Avoid migration errors

..because of existing indices. I think this is unnecessary, e.g. in
development.
This commit is contained in:
roschaefer 2020-03-26 16:41:32 +01:00
parent 2e1d5b6bb8
commit cedd0ac9e8
2 changed files with 24 additions and 11 deletions

View File

@ -15,12 +15,18 @@ export async function up(next) {
await transaction.commit() await transaction.commit()
next() next()
} catch (error) { } catch (error) {
// eslint-disable-next-line no-console const { message } = error
console.log(error) if (message.includes('There already exists an index')) {
await transaction.rollback() // all fine
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('rolled back') console.log(message)
throw new Error(error) next()
} else {
await transaction.rollback()
// eslint-disable-next-line no-console
console.log('rolled back')
throw new Error(error)
}
} finally { } finally {
session.close() session.close()
} }

View File

@ -19,11 +19,18 @@ export async function up(next) {
await transaction.commit() await transaction.commit()
next() next()
} catch (error) { } catch (error) {
// eslint-disable-next-line no-console const { message } = error
console.log(error) if (message.includes('There already exists an index')) {
await transaction.rollback() // all fine
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('rolled back') console.log(message)
next()
} else {
await transaction.rollback()
// eslint-disable-next-line no-console
console.log('rolled back')
throw new Error(error)
}
} finally { } finally {
session.close() session.close()
} }