Skip to content

Commit affed1d

Browse files
committed
fix(db): make ToC migration compatible with MySQL
1 parent 6d2c3a2 commit affed1d

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
exports.up = async knex => {
22
await knex.schema
33
.alterTable('pages', table => {
4-
table.json('tocOptions').notNullable().defaultTo(JSON.stringify({
5-
min: 1,
6-
max: 2,
7-
useDefault: true
8-
}))
4+
table.json('tocOptions').nullable()
95
})
6+
await knex('pages').whereNull('tocOptions').update({
7+
tocOptions: JSON.stringify({
8+
min: 1,
9+
max: 2,
10+
useDefault: true
11+
})
12+
})
1013
}
1114

1215
exports.down = knex => { }

server/db/migrations/2.5.284.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
exports.up = async knex => {
22
await knex.schema
33
.alterTable('pages', table => {
4-
table.json('tocOptions').notNullable().defaultTo(JSON.stringify({
5-
min: 1,
6-
max: 2,
7-
useDefault: true
8-
}))
4+
table.json('tocOptions').nullable()
95
})
6+
await knex('pages').whereNull('tocOptions').update({
7+
tocOptions: JSON.stringify({
8+
min: 1,
9+
max: 2,
10+
useDefault: true
11+
})
12+
})
1013
}
1114

1215
exports.down = knex => { }

0 commit comments

Comments
 (0)