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.
55 lines
2.0 KiB
55 lines
2.0 KiB
5 years ago
|
/* global WIKI */
|
||
|
|
||
5 years ago
|
exports.up = async knex => {
|
||
5 years ago
|
const dbCompat = {
|
||
|
charset: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`),
|
||
|
selfCascadeDelete: WIKI.config.db.type !== 'mssql'
|
||
|
}
|
||
5 years ago
|
|
||
5 years ago
|
return knex.schema
|
||
5 years ago
|
.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')
|
||
5 years ago
|
})
|
||
|
.table('pageTree', table => {
|
||
5 years ago
|
if (dbCompat.selfCascadeDelete) {
|
||
|
table.integer('parent').unsigned().references('id').inTable('pageTree').onDelete('CASCADE')
|
||
|
} else {
|
||
|
table.integer('parent').unsigned()
|
||
|
}
|
||
5 years ago
|
table.integer('pageId').unsigned().references('id').inTable('pages').onDelete('CASCADE')
|
||
5 years ago
|
table.string('localeCode', 5).references('code').inTable('locales')
|
||
5 years ago
|
})
|
||
|
}
|
||
|
|
||
|
exports.down = knex => {
|
||
5 years ago
|
const dbCompat = {
|
||
|
charset: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`),
|
||
|
selfCascadeDelete: WIKI.config.db.type !== 'mssql'
|
||
|
}
|
||
5 years ago
|
return knex.schema
|
||
5 years ago
|
.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')
|
||
5 years ago
|
})
|
||
|
.table('pageTree', table => {
|
||
|
table.integer('parent').unsigned().references('id').inTable('pageTree')
|
||
|
table.integer('pageId').unsigned().references('id').inTable('pages')
|
||
5 years ago
|
table.string('localeCode', 5).references('code').inTable('locales')
|
||
5 years ago
|
})
|
||
|
}
|