Fix broken migration introduced in 2.2.0-rc.1

pull/2822/head
Chocobozzz 2020-05-25 08:58:42 +02:00
parent c123027fd9
commit d2a5c4e150
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 39 additions and 31 deletions

View File

@ -14,7 +14,7 @@ import { CONFIG, registerConfigChangedHandler } from './config'
// ---------------------------------------------------------------------------
const LAST_MIGRATION_VERSION = 505
const LAST_MIGRATION_VERSION = 510
// ---------------------------------------------------------------------------

View File

@ -1,30 +0,0 @@
import * as Sequelize from 'sequelize'
async function up (utils: {
transaction: Sequelize.Transaction
queryInterface: Sequelize.QueryInterface
sequelize: Sequelize.Sequelize
}): Promise<void> {
const metadata = {
type: Sequelize.JSONB,
allowNull: true
}
await utils.queryInterface.addColumn('videoFile', 'metadata', metadata)
const metadataUrl = {
type: Sequelize.STRING,
allowNull: true
}
await utils.queryInterface.addColumn('videoFile', 'metadataUrl', metadataUrl)
}
function down (options) {
throw new Error('Not implemented.')
}
export {
up,
down
}

View File

@ -0,0 +1,38 @@
import * as Sequelize from 'sequelize'
async function up (utils: {
transaction: Sequelize.Transaction
queryInterface: Sequelize.QueryInterface
sequelize: Sequelize.Sequelize
}): Promise<void> {
// We made a mistake with the migration in 2.2.0-rc.1
// Docker containers did not include this migration file
// So we check the table definition and add the column if it does not exist
const tableDefinition = await utils.queryInterface.describeTable('videoFile')
if (!tableDefinition['metadata']) {
const metadata = {
type: Sequelize.JSONB,
allowNull: true
}
await utils.queryInterface.addColumn('videoFile', 'metadata', metadata)
}
if (!tableDefinition['metadataUrl']) {
const metadataUrl = {
type: Sequelize.STRING,
allowNull: true
}
await utils.queryInterface.addColumn('videoFile', 'metadataUrl', metadataUrl)
}
}
function down (options) {
throw new Error('Not implemented.')
}
export {
up,
down
}