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

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

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

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