Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

Commit a2032e7

Browse files
committed
fix: make migrate down work on migrations
Ensure that irreversible migrations are marked as such, that type conversions are implemented correctly, and that the changes are executed in the right order.
1 parent 8e7e4b3 commit a2032e7

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

migrations/1581725957097_del-password.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,4 @@ exports.up = function (pgm) {
22
pgm.dropColumns('users', ['password'])
33
}
44

5-
exports.down = function (pgm) {
6-
pgm.addColumns('users', {
7-
password: { type: 'string', notNull: true }
8-
})
9-
}
5+
exports.down = false

migrations/1582424634372_string-uuids.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exports.up = function (pgm) {
55
}
66

77
exports.down = function (pgm) {
8-
pgm.alterColumn('users', 'id', { type: 'uuid' })
9-
pgm.alterColumn('solves', 'id', { type: 'uuid' })
10-
pgm.alterColumn('solves', 'userid', { type: 'uuid' })
8+
pgm.alterColumn('users', 'id', { type: 'uuid', using: 'id::uuid' })
9+
pgm.alterColumn('solves', 'id', { type: 'uuid', using: 'id::uuid' })
10+
pgm.alterColumn('solves', 'userid', { type: 'uuid', using: 'id::uuid' })
1111
}

migrations/1585799727940_add-ctftime-id.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ exports.up = function (pgm) {
77
}
88

99
exports.down = function (pgm) {
10-
pgm.dropColumns('users', ['ctftime_id'])
11-
pgm.alterColumn('users', 'email', { notNull: true })
1210
pgm.dropConstraint('users', 'require_email_or_ctftime_id')
11+
pgm.alterColumn('users', 'email', { notNull: true })
12+
pgm.dropColumns('users', ['ctftime_id'])
1313
}

0 commit comments

Comments
 (0)