From 109d4a7f017e5ba18045f308158a71399a1b08cd Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 19 Jun 2023 09:55:56 +0200 Subject: Add thumbnail disk database migration --- .../initializers/migrations/0780-thumbnail-disk.ts | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 server/initializers/migrations/0780-thumbnail-disk.ts (limited to 'server') diff --git a/server/initializers/migrations/0780-thumbnail-disk.ts b/server/initializers/migrations/0780-thumbnail-disk.ts new file mode 100644 index 000000000..0824c042e --- /dev/null +++ b/server/initializers/migrations/0780-thumbnail-disk.ts @@ -0,0 +1,47 @@ +import * as Sequelize from 'sequelize' + +async function up (utils: { + transaction: Sequelize.Transaction + queryInterface: Sequelize.QueryInterface + sequelize: Sequelize.Sequelize +}): Promise { + const { transaction } = utils + + { + const data = { + type: Sequelize.BOOLEAN, + allowNull: true, + defaultValue: true + } + + await utils.queryInterface.addColumn('thumbnail', 'onDisk', data, { transaction }) + } + + { + // Remote previews are not on the disk + await utils.sequelize.query( + 'UPDATE "thumbnail" SET "onDisk" = FALSE ' + + 'WHERE "type" = 2 AND "videoId" NOT IN (SELECT "id" FROM "video" WHERE "remote" IS FALSE)', + { transaction } + ) + } + + { + const data = { + type: Sequelize.BOOLEAN, + allowNull: false, + defaultValue: null + } + + await utils.queryInterface.changeColumn('thumbnail', 'onDisk', data, { transaction }) + } +} + +function down (options) { + throw new Error('Not implemented.') +} + +export { + up, + down +} -- cgit v1.2.3