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

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

export const up: Migration = async ({ context }) => {
  await safeApplyColumnChanges(context, {
    checkout_sessions: [
      {
        name: 'setup_intent_id',
        field: {
          type: DataTypes.STRING(30),
          allowNull: true,
        },
      },
    ],
  });
};

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