Catch more errors

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
Tilman Vatteroth 2020-12-02 17:22:27 +01:00
parent 4ae80a3ed0
commit 120225947f
No known key found for this signature in database
GPG key ID: DEBDB3F34641B019
9 changed files with 31 additions and 10 deletions

View file

@ -21,9 +21,8 @@ module.exports = {
defaultValue: 0 defaultValue: 0
}) })
}).catch(function (error) { }).catch(function (error) {
if (error.message === 'SQLITE_ERROR: duplicate column name: shortid' || if (error.message === 'column "shortid" of relation "Notes" already exists' ||
error.message === 'column "shortid" of relation "Notes" already exists' || error.message.toLowerCase().includes('duplicate column name')) {
error.message.toLowerCase().includes("duplicate column name 'shortid'")) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('Migration has already run… ignoring.') console.log('Migration has already run… ignoring.')
} else { } else {

View file

@ -8,7 +8,8 @@ module.exports = {
type: Sequelize.DATE type: Sequelize.DATE
}) })
}).catch(function (error) { }).catch(function (error) {
if (error.message === 'SQLITE_ERROR: duplicate column name: lastchangeuserId' || error.message === "ER_DUP_FIELDNAME: Duplicate column name 'lastchangeuserId'" || error.message === 'column "lastchangeuserId" of relation "Notes" already exists') { if (error.message === 'column "lastchangeuserId" of relation "Notes" already exists' ||
error.message.toLowerCase().includes('duplicate column name')) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('Migration has already run… ignoring.') console.log('Migration has already run… ignoring.')
} else { } else {

View file

@ -8,7 +8,8 @@ module.exports = {
indicesType: 'UNIQUE' indicesType: 'UNIQUE'
}) })
}).catch(function (error) { }).catch(function (error) {
if (error.message === 'SQLITE_ERROR: duplicate column name: alias' || error.message === "ER_DUP_FIELDNAME: Duplicate column name 'alias'" || error.message === 'column "alias" of relation "Notes" already exists') { if (error.message.toLowerCase().includes('duplicate column name') ||
error.message === 'column "alias" of relation "Notes" already exists') {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('Migration has already run… ignoring.') console.log('Migration has already run… ignoring.')
} else { } else {

View file

@ -4,7 +4,8 @@ module.exports = {
return queryInterface.addColumn('Users', 'accessToken', Sequelize.STRING).then(function () { return queryInterface.addColumn('Users', 'accessToken', Sequelize.STRING).then(function () {
return queryInterface.addColumn('Users', 'refreshToken', Sequelize.STRING) return queryInterface.addColumn('Users', 'refreshToken', Sequelize.STRING)
}).catch(function (error) { }).catch(function (error) {
if (error.message === 'SQLITE_ERROR: duplicate column name: accessToken' || error.message === "ER_DUP_FIELDNAME: Duplicate column name 'accessToken'" || error.message === 'column "accessToken" of relation "Users" already exists') { if (error.message.toLowerCase().includes('duplicate column name') ||
error.message === 'column "accessToken" of relation "Users" already exists') {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('Migration has already run… ignoring.') console.log('Migration has already run… ignoring.')
} else { } else {

View file

@ -16,7 +16,8 @@ module.exports = {
updatedAt: Sequelize.DATE updatedAt: Sequelize.DATE
}) })
}).catch(function (error) { }).catch(function (error) {
if (error.message === 'SQLITE_ERROR: duplicate column name: savedAt' | error.message === "ER_DUP_FIELDNAME: Duplicate column name 'savedAt'" || error.message === 'column "savedAt" of relation "Notes" already exists') { if (error.message.toLowerCase().includes('duplicate column name') ||
error.message === 'column "savedAt" of relation "Notes" already exists') {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('Migration has already run… ignoring.') console.log('Migration has already run… ignoring.')
} else { } else {

View file

@ -2,7 +2,8 @@
module.exports = { module.exports = {
up: function (queryInterface, Sequelize) { up: function (queryInterface, Sequelize) {
return queryInterface.addColumn('Notes', 'deletedAt', Sequelize.DATE).catch(function (error) { return queryInterface.addColumn('Notes', 'deletedAt', Sequelize.DATE).catch(function (error) {
if (error.message === 'SQLITE_ERROR: duplicate column name: deletedAt' || error.message === "ER_DUP_FIELDNAME: Duplicate column name 'deletedAt'" || error.message === 'column "deletedAt" of relation "Notes" already exists') { if (error.message.toLowerCase().includes('duplicate column name') ||
error.message === 'column "deletedAt" of relation "Notes" already exists') {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('Migration has already run… ignoring.') console.log('Migration has already run… ignoring.')
} else { } else {

View file

@ -3,7 +3,8 @@ module.exports = {
up: function (queryInterface, Sequelize) { up: function (queryInterface, Sequelize) {
return queryInterface.addColumn('Users', 'email', Sequelize.TEXT).then(function () { return queryInterface.addColumn('Users', 'email', Sequelize.TEXT).then(function () {
return queryInterface.addColumn('Users', 'password', Sequelize.TEXT).catch(function (error) { return queryInterface.addColumn('Users', 'password', Sequelize.TEXT).catch(function (error) {
if (error.message === "ER_DUP_FIELDNAME: Duplicate column name 'password'" || error.message === 'column "password" of relation "Users" already exists') { if (error.message.toLowerCase().includes('duplicate column name') ||
error.message === 'column "password" of relation "Users" already exists') {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('Migration has already run… ignoring.') console.log('Migration has already run… ignoring.')
} else { } else {
@ -11,7 +12,8 @@ module.exports = {
} }
}) })
}).catch(function (error) { }).catch(function (error) {
if (error.message === 'SQLITE_ERROR: duplicate column name: email' || error.message === "ER_DUP_FIELDNAME: Duplicate column name 'email'" || error.message === 'column "email" of relation "Users" already exists') { if (error.message.toLowerCase().includes('duplicate column name') ||
error.message === 'column "email" of relation "Users" already exists') {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('Migration has already run… ignoring.') console.log('Migration has already run… ignoring.')
} else { } else {

View file

@ -4,6 +4,14 @@ module.exports = {
return queryInterface.addColumn('Users', 'deleteToken', { return queryInterface.addColumn('Users', 'deleteToken', {
type: Sequelize.UUID, type: Sequelize.UUID,
defaultValue: Sequelize.UUIDV4 defaultValue: Sequelize.UUIDV4
}).catch(function (error) {
if (error.message.toLowerCase().includes('duplicate column name') ||
error.message === 'column "deleteToken" of relation "Users" already exists') {
// eslint-disable-next-line no-console
console.log('Migration has already run… ignoring.')
} else {
throw error
}
}) })
}, },

View file

@ -45,6 +45,13 @@ module.exports = {
}, },
onDelete: 'cascade' onDelete: 'cascade'
}) })
}).catch(function (error) {
if (error.message.toLowerCase().includes('duplicate key on write or update')) {
// eslint-disable-next-line no-console
console.log('Migration has already run… ignoring.')
} else {
throw error
}
}) })
}, },