import { pool } from "./config/db.js";

const tailoringServices = [
  { service_name: "Basta / Ruedo", service_code: "HEM_TAILOR", price: 120.00, unit: "item" },
  { service_name: "Ajuste de Manga/Cintura", service_code: "ADJ_TAILOR", price: 250.00, unit: "item" },
  { service_name: "Cambio de Cierre", service_code: "ZIP_TAILOR", price: 150.00, unit: "item" },
  { service_name: "Parche / Zurcido", service_code: "PATCH_TAILOR", price: 80.00, unit: "item" }
];

async function seed() {
  try {
    for (const service of tailoringServices) {
      await pool.query(
        `INSERT INTO services (service_name, service_code, price, unit) 
         VALUES (?, ?, ?, ?) 
         ON DUPLICATE KEY UPDATE service_name = VALUES(service_name), price = VALUES(price), unit = VALUES(unit)`,
        [service.service_name, service.service_code, service.price, service.unit]
      );
      console.log(`Seeded: ${service.service_name}`);
    }
    console.log("Seeding complete!");
    process.exit(0);
  } catch (error) {
    console.error("Seeding failed:", error);
    process.exit(1);
  }
}

seed();
