|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+const readline = require('readline')
|
|
|
2
|
+const process = require('process')
|
|
|
3
|
+
|
|
|
4
|
+
|
|
|
5
|
+exports.up = function (knex) {
|
|
|
6
|
+ return knex.schema.hasColumn('signups', 'absent').then(absent => {
|
|
|
7
|
+ if (!absent) {
|
|
|
8
|
+
|
|
|
9
|
+ const r1 = readline.createInterface({
|
|
|
10
|
+ input: process.stdin,
|
|
|
11
|
+ output: process.stdout
|
|
|
12
|
+ })
|
|
|
13
|
+ return new Promise((res, rej) => {
|
|
|
14
|
+ return knex.schema.dropTable('signups').then(_ => {
|
|
|
15
|
+ return knex.schema.createTable('signups', function (table) {
|
|
|
16
|
+ table.increments('id').primary()
|
|
|
17
|
+ table.unique(['raidid', 'characterid'])
|
|
|
18
|
+ table.integer('raidid')
|
|
|
19
|
+ table.foreign('raidid').references('id').inTable('raids').onDelete('CASCADE')
|
|
|
20
|
+ table.integer('characterid')
|
|
|
21
|
+ table.foreign('characterid').references('id').inTable('characters').onDelete('CASCADE')
|
|
|
22
|
+ table.boolean('benched').defaultTo('false')
|
|
|
23
|
+ table.boolean('late')
|
|
|
24
|
+ table.boolean('absent').defaultTo(false)
|
|
|
25
|
+ table.timestamp('timestamp').defaultTo(knex.fn.now())
|
|
|
26
|
+ table.string('memo').nullable()
|
|
|
27
|
+ res()
|
|
|
28
|
+ }).catch(rej)
|
|
|
29
|
+ })
|
|
|
30
|
+ })
|
|
|
31
|
+ }
|
|
|
32
|
+ })
|
|
|
33
|
+}
|
|
|
34
|
+
|
|
|
35
|
+
|
|
|
36
|
+exports.down = function (knex) {
|
|
|
37
|
+ return knex.schema.table('signups', function (table) {
|
|
|
38
|
+ table.dropColumn('absent')
|
|
|
39
|
+ })
|
|
|
40
|
+}
|