import {
  Op,
  type CreationAttributes,
  type QueryInterface,
} from 'sequelize';
import { PRODUCT_CAMPUS_SEED_ROWS } from '@/shared/constants/campuses';
import type { Campuses } from '@/db/models/campuses';

export default {
  up: async (queryInterface: QueryInterface) => {
    const createdAt = new Date();
    const updatedAt = new Date();

    const rows: CreationAttributes<Campuses>[] = PRODUCT_CAMPUS_SEED_ROWS.map(
      (campus) => ({ ...campus, createdAt, updatedAt }),
    );

    await queryInterface.bulkInsert('campuses', rows);
  },

  down: async (queryInterface: QueryInterface) => {
    await queryInterface.bulkDelete('campuses', {
      id: {
        [Op.in]: PRODUCT_CAMPUS_SEED_ROWS.map((campus) => campus.id),
      },
    });
  },
};
