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()
|
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()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user