import * as Sequelize from 'sequelize'

async function up (utils: {
  transaction: Sequelize.Transaction
  sequelize: Sequelize.Sequelize
}): Promise<void> {
  for (const table of [ 'liveVideo', 'event' ]) {
    await utils.sequelize.query(`ALTER TABLE "${table}" ADD COLUMN IF NOT EXISTS "thumbnailData" BYTEA`, { transaction: utils.transaction })
    await utils.sequelize.query(`ALTER TABLE "${table}" ADD COLUMN IF NOT EXISTS "thumbnailMimeType" VARCHAR(255)`, { transaction: utils.transaction })
    await utils.sequelize.query(`ALTER TABLE "${table}" ADD COLUMN IF NOT EXISTS "thumbnailSize" BIGINT`, { transaction: utils.transaction })
    await utils.sequelize.query(`ALTER TABLE "${table}" ADD COLUMN IF NOT EXISTS "thumbnailEtag" VARCHAR(64)`, { transaction: utils.transaction })
  }
}

function down () {
  throw new Error('Not implemented.')
}

export {
  up,
  down
}
