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

export const up: Migration = async ({ context }) => {
  // Add vendor_type column to product_vendors table
  await safeApplyColumnChanges(context, {
    product_vendors: [
      {
        name: 'vendor_type',
        field: {
          type: 'STRING',
          allowNull: false,
          defaultValue: 'launcher',
        },
      },
    ],
  });
  await context.removeColumn('product_vendors', 'default_commission_rate');
  await context.removeColumn('product_vendors', 'default_commission_type');
  await context.removeColumn('product_vendors', 'order_create_params');
  await context.removeColumn('product_vendors', 'webhook_path');
};

export const down: Migration = async ({ context }) => {
  // Remove vendor_type column if we need to rollback
  await context.removeColumn('product_vendors', 'vendor_type');
};
