fix migrations
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
const readline = require('readline')
|
||||
const process = require('process')
|
||||
|
||||
|
||||
exports.up = function (knex) {
|
||||
return knex.schema.hasColumn('signups', 'absent').then(absent => {
|
||||
if (!absent) {
|
||||
|
||||
const r1 = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout
|
||||
})
|
||||
return new Promise((res, rej) => {
|
||||
return knex.schema.dropTable('signups').then(_ => {
|
||||
return knex.schema.createTable('signups', function (table) {
|
||||
table.increments('id').primary()
|
||||
table.unique(['raidid', 'characterid'])
|
||||
table.integer('raidid')
|
||||
table.foreign('raidid').references('id').inTable('raids').onDelete('CASCADE')
|
||||
table.integer('characterid')
|
||||
table.foreign('characterid').references('id').inTable('characters').onDelete('CASCADE')
|
||||
table.boolean('benched').defaultTo('false')
|
||||
table.boolean('late')
|
||||
table.boolean('absent').defaultTo(false)
|
||||
table.timestamp('timestamp').defaultTo(knex.fn.now())
|
||||
table.string('memo').nullable()
|
||||
res()
|
||||
}).catch(rej)
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
exports.down = function (knex) {
|
||||
return knex.schema.table('signups', function (table) {
|
||||
table.dropColumn('absent')
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user