import { PrismaClient } from "@prisma/client";
import { RECIPE_TAG_DEFINITIONS } from "../src/modules/recipes/application/services/recipeTags";

const prisma = new PrismaClient();

async function main() {
  for (const { slug, name } of RECIPE_TAG_DEFINITIONS) {
    await prisma.tag.upsert({
      where: { slug },
      update: { name },
      create: { slug, name },
    });
  }

  console.log(`Synced ${RECIPE_TAG_DEFINITIONS.length} recipe tags.`);
}

main()
  .catch((error) => {
    console.error("Failed to sync recipe tags.", error);
    process.exitCode = 1;
  })
  .finally(async () => {
    await prisma.$disconnect();
  });
