From d2a5c4e15003d1e8904b389810d78e26db2cebfc Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 25 May 2020 08:58:42 +0200 Subject: Fix broken migration introduced in 2.2.0-rc.1 --- server/initializers/constants.ts | 2 +- .../migrations/0485-video-file-metadata.ts | 30 ----------------- .../migrations/0510-video-file-metadata.ts | 38 ++++++++++++++++++++++ 3 files changed, 39 insertions(+), 31 deletions(-) delete mode 100644 server/initializers/migrations/0485-video-file-metadata.ts create mode 100644 server/initializers/migrations/0510-video-file-metadata.ts diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 676d9804b..d201df3d8 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -14,7 +14,7 @@ import { CONFIG, registerConfigChangedHandler } from './config' // --------------------------------------------------------------------------- -const LAST_MIGRATION_VERSION = 505 +const LAST_MIGRATION_VERSION = 510 // --------------------------------------------------------------------------- diff --git a/server/initializers/migrations/0485-video-file-metadata.ts b/server/initializers/migrations/0485-video-file-metadata.ts deleted file mode 100644 index 5d95be024..000000000 --- a/server/initializers/migrations/0485-video-file-metadata.ts +++ /dev/null @@ -1,30 +0,0 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - - 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 -} diff --git a/server/initializers/migrations/0510-video-file-metadata.ts b/server/initializers/migrations/0510-video-file-metadata.ts new file mode 100644 index 000000000..be9feb47a --- /dev/null +++ b/server/initializers/migrations/0510-video-file-metadata.ts @@ -0,0 +1,38 @@ +import * as Sequelize from 'sequelize' + +async function up (utils: { + transaction: Sequelize.Transaction + queryInterface: Sequelize.QueryInterface + sequelize: Sequelize.Sequelize +}): Promise { + + // 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 +} -- cgit v1.2.3