aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrations/0735-video-channel-sync-import-foreign-key.ts
blob: ffe0b11abe578636b3b72c358d86a1e9c8714623 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import * as Sequelize from 'sequelize'

async function up (utils: {
  transaction: Sequelize.Transaction
  queryInterface: Sequelize.QueryInterface
  sequelize: Sequelize.Sequelize
  db: any
}): Promise<void> {
  await utils.queryInterface.addColumn('videoImport', 'videoChannelSyncId', {
    type: Sequelize.INTEGER,
    defaultValue: null,
    allowNull: true,
    references: {
      model: 'videoChannelSync',
      key: 'id'
    },
    onUpdate: 'CASCADE',
    onDelete: 'SET NULL'
  }, { transaction: utils.transaction })
}

async function down (utils: {
  queryInterface: Sequelize.QueryInterface
  transaction: Sequelize.Transaction
}) {
  await utils.queryInterface.dropTable('videoChannelSync', { transaction: utils.transaction })
}

export {
  up,
  down
}