Add thumbnail disk database migration

This commit is contained in:
Chocobozzz 2023-06-19 09:55:56 +02:00
parent 89becbcb37
commit 109d4a7f01
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,47 @@
import * as Sequelize from 'sequelize'
async function up (utils: {
transaction: Sequelize.Transaction
queryInterface: Sequelize.QueryInterface
sequelize: Sequelize.Sequelize
}): Promise<void> {
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
}