mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Code creep: Avoid migration errors
..because of existing indices. I think this is unnecessary, e.g. in development.
This commit is contained in:
parent
2e1d5b6bb8
commit
cedd0ac9e8
@ -15,12 +15,18 @@ export async function up(next) {
|
||||
await transaction.commit()
|
||||
next()
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(error)
|
||||
await transaction.rollback()
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('rolled back')
|
||||
throw new Error(error)
|
||||
const { message } = error
|
||||
if (message.includes('There already exists an index')) {
|
||||
// all fine
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(message)
|
||||
next()
|
||||
} else {
|
||||
await transaction.rollback()
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('rolled back')
|
||||
throw new Error(error)
|
||||
}
|
||||
} finally {
|
||||
session.close()
|
||||
}
|
||||
|
||||
@ -19,11 +19,18 @@ export async function up(next) {
|
||||
await transaction.commit()
|
||||
next()
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(error)
|
||||
await transaction.rollback()
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('rolled back')
|
||||
const { message } = error
|
||||
if (message.includes('There already exists an index')) {
|
||||
// all fine
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(message)
|
||||
next()
|
||||
} else {
|
||||
await transaction.rollback()
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('rolled back')
|
||||
throw new Error(error)
|
||||
}
|
||||
} finally {
|
||||
session.close()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user