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

export const up: Migration = async ({ context }) => {
  await safeApplyColumnChanges(context, {
    coupons: [
      {
        name: 'description',
        field: {
          type: DataTypes.TEXT,
          allowNull: true,
        },
      },
    ],
    promotion_codes: [
      {
        name: 'description',
        field: {
          type: DataTypes.TEXT,
          allowNull: true,
        },
      },
    ],
  });
};

export const down: Migration = async ({ context }) => {
  await context.removeColumn('coupons', 'description');
  await context.removeColumn('promotion_codes', 'description');
};
