Skip to content

Commit bb243dc

Browse files
committed
fix: config table character limit
1 parent 008c55a commit bb243dc

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/server/db.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async function migrate(db) {
4545
if (!exists) {
4646
await db.schema.createTable('config', table => {
4747
table.string('key').primary()
48-
table.string('value')
48+
table.text('value')
4949
})
5050
await db('config').insert({ key: 'version', value: '0' })
5151
}
@@ -426,4 +426,19 @@ const migrations = [
426426
const value = JSON.stringify(settings)
427427
await db('config').where('key', 'settings').update({ value })
428428
},
429+
// change config table 'value' column from string(255) to text
430+
async db => {
431+
await db.transaction(async trx => {
432+
// make replacement table
433+
await trx.schema.createTable('_config_new', table => {
434+
table.string('key').primary()
435+
table.text('value') // in older versions this was string(255) but we want text
436+
})
437+
// copy everything over
438+
await trx.raw('INSERT INTO _config_new (key, value) SELECT key, value FROM config')
439+
// swap and destroy old
440+
await trx.schema.dropTable('config')
441+
await trx.schema.renameTable('_config_new', 'config')
442+
})
443+
},
429444
]

0 commit comments

Comments
 (0)