2.0.0-beta.293.js 673 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10
/* global WIKI */

exports.up = knex => {
  const dbCompat = {
    charset: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`)
  }
  return knex.schema
    .createTable('pageLinks', table => {
      if (dbCompat.charset) { table.charset('utf8mb4') }
      table.increments('id').primary()
Nick's avatar
Nick committed
11 12 13 14 15 16
      table.integer('pageId').unsigned().references('id').inTable('pages').onDelete('CASCADE')
      table.string('path').notNullable()
      table.string('localeCode', 5).notNullable()
    })
    .table('pageLinks', table => {
      table.index(['path', 'localeCode'])
17 18 19 20 21 22 23
    })
}

exports.down = knex => {
  return knex.schema
    .dropTableIfExists('pageLinks')
}