feat: delete page
This commit is contained in:
15
server/db/migrations/2.0.0-beta.11.js
Normal file
15
server/db/migrations/2.0.0-beta.11.js
Normal file
@@ -0,0 +1,15 @@
|
||||
exports.up = knex => {
|
||||
return knex.schema
|
||||
.table('pageHistory', table => {
|
||||
table.string('action').defaultTo('updated')
|
||||
table.dropForeign('pageId')
|
||||
})
|
||||
}
|
||||
|
||||
exports.down = knex => {
|
||||
return knex.schema
|
||||
.table('pageHistory', table => {
|
||||
table.dropColumn('action')
|
||||
table.integer('pageId').unsigned().references('id').inTable('pages')
|
||||
})
|
||||
}
|
28
server/db/migrator-source.js
Normal file
28
server/db/migrator-source.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const path = require('path')
|
||||
const fs = require('fs-extra')
|
||||
const semver = require('semver')
|
||||
|
||||
/* global WIKI */
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Gets the migration names
|
||||
* @returns Promise<string[]>
|
||||
*/
|
||||
async getMigrations() {
|
||||
const absoluteDir = path.join(WIKI.SERVERPATH, 'db/migrations')
|
||||
const migrationFiles = await fs.readdirAsync(absoluteDir)
|
||||
return migrationFiles.sort(semver.compare).map(m => ({
|
||||
file: m,
|
||||
directory: absoluteDir
|
||||
}))
|
||||
},
|
||||
|
||||
getMigrationName(migration) {
|
||||
return migration.file;
|
||||
},
|
||||
|
||||
getMigration(migration) {
|
||||
return require(path.join(WIKI.SERVERPATH, 'db/migrations', migration.file));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user