import { DataTypes } from 'sequelize';

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

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

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