Skip to content

Commit 48ddcef

Browse files
authored
Merge pull request #894 from hcaloto/fixMigrationIssues
Add missing catch blocks for migration from 1.1.1 to 1.2.0
2 parents 93a3ce1 + 26a14dd commit 48ddcef

8 files changed

+56
-2
lines changed

lib/migrations/20150702001020-update-to-0_3_1.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ module.exports = {
2020
type: Sequelize.INTEGER,
2121
defaultValue: 0
2222
})
23+
}).catch(function (error) {
24+
if (error.message === "ER_DUP_FIELDNAME: Duplicate column name 'shortid'") {
25+
console.log('Migration has already run… ignoring.')
26+
} else {
27+
throw error
28+
}
2329
})
2430
},
2531

lib/migrations/20160112220142-note-add-lastchange.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ module.exports = {
77
return queryInterface.addColumn('Notes', 'lastchangeAt', {
88
type: Sequelize.DATE
99
})
10+
}).catch(function (error) {
11+
if (error.message === "ER_DUP_FIELDNAME: Duplicate column name 'lastchangeuserId'") {
12+
console.log('Migration has already run… ignoring.')
13+
} else {
14+
throw error
15+
}
1016
})
1117
},
1218

lib/migrations/20160420180355-note-add-alias.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ module.exports = {
77
return queryInterface.addIndex('Notes', ['alias'], {
88
indicesType: 'UNIQUE'
99
})
10+
}).catch(function (error) {
11+
if (error.message === "ER_DUP_FIELDNAME: Duplicate column name 'alias'") {
12+
console.log('Migration has already run… ignoring.')
13+
} else {
14+
throw error
15+
}
1016
})
1117
},
1218

lib/migrations/20160515114000-user-add-tokens.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ module.exports = {
33
up: function (queryInterface, Sequelize) {
44
return queryInterface.addColumn('Users', 'accessToken', Sequelize.STRING).then(function () {
55
return queryInterface.addColumn('Users', 'refreshToken', Sequelize.STRING)
6+
}).catch(function (error) {
7+
if (error.message === "ER_DUP_FIELDNAME: Duplicate column name 'accessToken'") {
8+
console.log('Migration has already run… ignoring.')
9+
} else {
10+
throw error
11+
}
612
})
713
},
814

lib/migrations/20160607060246-support-revision.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ module.exports = {
1515
createdAt: Sequelize.DATE,
1616
updatedAt: Sequelize.DATE
1717
})
18+
}).catch(function (error) {
19+
if (error.message === "ER_DUP_FIELDNAME: Duplicate column name 'savedAt'") {
20+
console.log('Migration has already run… ignoring.')
21+
} else {
22+
throw error
23+
}
1824
})
1925
},
2026

lib/migrations/20160703062241-support-authorship.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ module.exports = {
1616
createdAt: Sequelize.DATE,
1717
updatedAt: Sequelize.DATE
1818
})
19+
}).catch(function (error) {
20+
if (error.message === "ER_DUP_FIELDNAME: Duplicate column name 'authorship'") {
21+
console.log('Migration has already run… ignoring.')
22+
} else {
23+
throw error
24+
}
1925
})
2026
},
2127

lib/migrations/20161009040430-support-delete-note.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
'use strict'
22
module.exports = {
33
up: function (queryInterface, Sequelize) {
4-
return queryInterface.addColumn('Notes', 'deletedAt', Sequelize.DATE)
4+
return queryInterface.addColumn('Notes', 'deletedAt', Sequelize.DATE).catch(function (error) {
5+
if (error.message === "ER_DUP_FIELDNAME: Duplicate column name 'deletedAt'") {
6+
console.log('Migration has already run… ignoring.')
7+
} else {
8+
throw error
9+
}
10+
})
511
},
612

713
down: function (queryInterface, Sequelize) {

lib/migrations/20161201050312-support-email-signin.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@
22
module.exports = {
33
up: function (queryInterface, Sequelize) {
44
return queryInterface.addColumn('Users', 'email', Sequelize.TEXT).then(function () {
5-
return queryInterface.addColumn('Users', 'password', Sequelize.TEXT)
5+
return queryInterface.addColumn('Users', 'password', Sequelize.TEXT).catch(function (error) {
6+
if (error.message === "ER_DUP_FIELDNAME: Duplicate column name 'password'") {
7+
console.log('Migration has already run… ignoring.')
8+
} else {
9+
throw error
10+
}
11+
})
12+
}).catch(function (error) {
13+
if (error.message === "ER_DUP_FIELDNAME: Duplicate column name 'email'") {
14+
console.log('Migration has already run… ignoring.')
15+
} else {
16+
throw error
17+
}
618
})
719
},
820

0 commit comments

Comments
 (0)