mirror of https://github.com/Requarks/wiki.git
NGPixel
5 years ago
5 changed files with 53 additions and 36 deletions
Split View
Diff Options
-
4server/db/migrations-sqlite/2.0.0-rc.2.js
-
44server/db/migrations/2.0.0-rc.2.js
-
11server/jobs/rebuild-tree.js
-
6server/models/pages.js
-
24server/setup.js
@ -1,23 +1,53 @@ |
|||
/* global WIKI */ |
|||
|
|||
exports.up = knex => { |
|||
const dbCompat = { |
|||
charset: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`), |
|||
selfCascadeDelete: WIKI.config.db.type !== 'mssql' |
|||
} |
|||
return knex.schema |
|||
.table('pageTree', table => { |
|||
table.dropColumn('parent') |
|||
table.dropColumn('pageId') |
|||
.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') |
|||
}) |
|||
.table('pageTree', table => { |
|||
table.integer('parent').unsigned().references('id').inTable('pageTree').onDelete('CASCADE') |
|||
if (dbCompat.selfCascadeDelete) { |
|||
table.integer('parent').unsigned().references('id').inTable('pageTree').onDelete('CASCADE') |
|||
} else { |
|||
table.integer('parent').unsigned() |
|||
} |
|||
table.integer('pageId').unsigned().references('id').inTable('pages').onDelete('CASCADE') |
|||
table.string('localeCode', 5).references('code').inTable('locales') |
|||
}) |
|||
} |
|||
|
|||
exports.down = knex => { |
|||
const dbCompat = { |
|||
charset: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`), |
|||
selfCascadeDelete: WIKI.config.db.type !== 'mssql' |
|||
} |
|||
return knex.schema |
|||
.table('pageTree', table => { |
|||
table.dropColumn('parent') |
|||
table.dropColumn('pageId') |
|||
.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') |
|||
}) |
|||
.table('pageTree', table => { |
|||
table.integer('parent').unsigned().references('id').inTable('pageTree') |
|||
table.integer('pageId').unsigned().references('id').inTable('pages') |
|||
table.string('localeCode', 5).references('code').inTable('locales') |
|||
}) |
|||
} |
Write
Preview
Loading…
Cancel
Save