2019-10-26 03:02:33 +00:00
|
|
|
/* global WIKI */
|
|
|
|
|
2019-10-23 02:04:14 +00:00
|
|
|
exports.up = knex => {
|
2019-10-26 03:02:33 +00:00
|
|
|
const dbCompat = {
|
|
|
|
charset: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`),
|
|
|
|
selfCascadeDelete: WIKI.config.db.type !== 'mssql'
|
|
|
|
}
|
2019-10-23 02:04:14 +00:00
|
|
|
return knex.schema
|
2019-10-26 03:02:33 +00:00
|
|
|
.dropTable('pageTree')
|
|
|
|
.createTable('pageTree', table => {
|
|
|
|
if (dbCompat.charset) { table.charset('utf8mb4') }
|
|
|
|
table.integer('id').unsigned().primary()
|
|
|
|
table.string('path').notNullable()
|
|
|
|
table.integer('depth').unsigned().notNullable()
|
|
|
|
table.string('title').notNullable()
|
|
|
|
table.boolean('isPrivate').notNullable().defaultTo(false)
|
|
|
|
table.boolean('isFolder').notNullable().defaultTo(false)
|
|
|
|
table.string('privateNS')
|
2019-10-23 02:04:14 +00:00
|
|
|
})
|
|
|
|
.table('pageTree', table => {
|
2019-10-26 03:02:33 +00:00
|
|
|
if (dbCompat.selfCascadeDelete) {
|
|
|
|
table.integer('parent').unsigned().references('id').inTable('pageTree').onDelete('CASCADE')
|
|
|
|
} else {
|
|
|
|
table.integer('parent').unsigned()
|
|
|
|
}
|
2019-10-23 02:04:14 +00:00
|
|
|
table.integer('pageId').unsigned().references('id').inTable('pages').onDelete('CASCADE')
|
2019-10-26 03:02:33 +00:00
|
|
|
table.string('localeCode', 5).references('code').inTable('locales')
|
2019-10-23 02:04:14 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.down = knex => {
|
2019-10-26 03:02:33 +00:00
|
|
|
const dbCompat = {
|
|
|
|
charset: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`),
|
|
|
|
selfCascadeDelete: WIKI.config.db.type !== 'mssql'
|
|
|
|
}
|
2019-10-23 02:04:14 +00:00
|
|
|
return knex.schema
|
2019-10-26 03:02:33 +00:00
|
|
|
.dropTable('pageTree')
|
|
|
|
.createTable('pageTree', table => {
|
|
|
|
if (dbCompat.charset) { table.charset('utf8mb4') }
|
|
|
|
table.integer('id').primary()
|
|
|
|
table.string('path').notNullable()
|
|
|
|
table.integer('depth').unsigned().notNullable()
|
|
|
|
table.string('title').notNullable()
|
|
|
|
table.boolean('isPrivate').notNullable().defaultTo(false)
|
|
|
|
table.boolean('isFolder').notNullable().defaultTo(false)
|
|
|
|
table.string('privateNS')
|
2019-10-23 02:04:14 +00:00
|
|
|
})
|
|
|
|
.table('pageTree', table => {
|
|
|
|
table.integer('parent').unsigned().references('id').inTable('pageTree')
|
|
|
|
table.integer('pageId').unsigned().references('id').inTable('pages')
|
2019-10-26 03:02:33 +00:00
|
|
|
table.string('localeCode', 5).references('code').inTable('locales')
|
2019-10-23 02:04:14 +00:00
|
|
|
})
|
|
|
|
}
|