mirror of https://github.com/requarks/wiki
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
2.4 KiB
53 lines
2.4 KiB
6 years ago
|
exports.up = knex => {
|
||
|
return knex.schema
|
||
|
.renameTable('pageHistory', 'pageHistory_old')
|
||
|
.createTable('pageHistory', table => {
|
||
|
table.increments('id').primary()
|
||
|
table.string('path').notNullable()
|
||
|
table.string('hash').notNullable()
|
||
|
table.string('title').notNullable()
|
||
|
table.string('description')
|
||
|
table.boolean('isPrivate').notNullable().defaultTo(false)
|
||
|
table.boolean('isPublished').notNullable().defaultTo(false)
|
||
|
table.string('publishStartDate')
|
||
|
table.string('publishEndDate')
|
||
|
table.text('content')
|
||
|
table.string('contentType').notNullable()
|
||
|
table.string('createdAt').notNullable()
|
||
|
table.string('action').defaultTo('updated')
|
||
|
|
||
6 years ago
|
table.integer('pageId').unsigned()
|
||
6 years ago
|
table.string('editorKey').references('key').inTable('editors')
|
||
5 years ago
|
table.string('localeCode', 5).references('code').inTable('locales')
|
||
6 years ago
|
table.integer('authorId').unsigned().references('id').inTable('users')
|
||
|
})
|
||
6 years ago
|
.raw(`INSERT INTO pageHistory SELECT id,path,hash,title,description,isPrivate,isPublished,publishStartDate,publishEndDate,content,contentType,createdAt,'updated' AS action,pageId,editorKey,localeCode,authorId FROM pageHistory_old;`)
|
||
6 years ago
|
.dropTable('pageHistory_old')
|
||
|
}
|
||
|
|
||
|
exports.down = knex => {
|
||
|
return knex.schema
|
||
|
.renameTable('pageHistory', 'pageHistory_old')
|
||
|
.createTable('pageHistory', table => {
|
||
|
table.increments('id').primary()
|
||
|
table.string('path').notNullable()
|
||
|
table.string('hash').notNullable()
|
||
|
table.string('title').notNullable()
|
||
|
table.string('description')
|
||
|
table.boolean('isPrivate').notNullable().defaultTo(false)
|
||
|
table.boolean('isPublished').notNullable().defaultTo(false)
|
||
|
table.string('publishStartDate')
|
||
|
table.string('publishEndDate')
|
||
|
table.text('content')
|
||
|
table.string('contentType').notNullable()
|
||
|
table.string('createdAt').notNullable()
|
||
|
|
||
|
table.integer('pageId').unsigned().references('id').inTable('pages')
|
||
|
table.string('editorKey').references('key').inTable('editors')
|
||
5 years ago
|
table.string('localeCode', 5).references('code').inTable('locales')
|
||
6 years ago
|
table.integer('authorId').unsigned().references('id').inTable('users')
|
||
|
})
|
||
|
.raw('INSERT INTO pageHistory SELECT id,path,hash,title,description,isPrivate,isPublished,publishStartDate,publishEndDate,content,contentType,createdAt,NULL as pageId,editorKey,localeCode,authorId FROM pageHistory_old;')
|
||
|
.dropTable('pageHistory_old')
|
||
|
}
|