/* eslint-disable no-await-in-loop */
import { DataTypes } from 'sequelize';

import { Migration, safeApplyColumnChanges } from '../migrate';

export const up: Migration = async ({ context }) => {
  await safeApplyColumnChanges(context, {
    subscriptions: [
      {
        name: 'service_actions',
        field: {
          type: DataTypes.JSON,
          allowNull: true,
          defaultValue: '[]',
        },
      },
    ],
  });
};

export const down: Migration = async ({ context }) => {
  await context.removeColumn('subscriptions', 'service_actions');
};
