const { Pool } = require('pg');
const { PrismaPg } = require('@prisma/adapter-pg');
const { PrismaClient } = require('@prisma/client');

const connectionString = "postgres://postgres:P9cIY8Ji1iSXOCRs9q6WbOo5xeXCdzyQjYoQ511Zmq1RY8WHLU9YKBGyjDpJ02sa@65.109.236.58:6482/postgres";

const pool = new Pool({ connectionString });
const adapter = new PrismaPg(pool);
const prisma = new PrismaClient({ adapter });

const projects = [
  {
    slug: 'jdhm-genel-merkez',
    year: '2018',
    location: 'SAINT-AUGUSTIN-DE-DESMAURES',
    title: 'JDHM – GENEL MERKEZ',
    image: 'https://images.unsplash.com/photo-1486406146926-c627a92ad1ab?q=80&w=2070&auto=format&fit=crop',
    category: 'Ticari'
  },
  {
    slug: 'sale',
    year: '2019',
    location: 'MONTREAL, QC',
    title: 'ŞALE',
    image: 'https://images.unsplash.com/photo-1518780664697-55e3ad937233?q=80&w=2070&auto=format&fit=crop',
    category: 'Konut'
  },
  {
    slug: 'modern-muze',
    year: '2020',
    location: 'QUEBEC CITY, QC',
    title: 'MODERN MÜZE',
    image: 'https://images.unsplash.com/photo-1511818966892-d7d671e672a2?q=80&w=2070&auto=format&fit=crop',
    category: 'Kültürel'
  },
  {
    slug: 'orman-evi',
    year: '2022',
    location: 'VANCOUVER, BC',
    title: 'ORMAN EVİ',
    image: 'https://images.unsplash.com/photo-1500382017468-9049fed747ef?q=80&w=2070&auto=format&fit=crop',
    category: 'Konut'
  },
  {
    slug: 'kocina',
    year: '2023',
    location: 'SAINTE-FOY, QC',
    title: 'KOCINA',
    image: 'https://images.unsplash.com/photo-1487958449943-2429e8be8625?q=80&w=2070&auto=format&fit=crop',
    category: 'Ticari'
  },
  {
    slug: 'yamac-evi',
    year: '2022',
    location: 'MONT-TREMBLANT, QC',
    title: 'YAMAÇ EVİ',
    image: 'https://images.unsplash.com/photo-1497366216548-37526070297c?q=80&w=2070&auto=format&fit=crop',
    category: 'Konut'
  },
  {
    slug: 'makusham-studyo',
    year: '2021',
    location: 'LÉVIS, QC',
    title: 'MAKUSHAM STÜDYO',
    image: 'https://images.unsplash.com/photo-1431540015161-0bf868a2d407?q=80&w=2070&auto=format&fit=crop',
    category: 'Kültürel'
  },
  {
    slug: 'must-societe',
    year: '2023',
    location: 'BROSSARD, QC',
    title: 'MUST SOCIÉTÉ',
    image: 'https://images.unsplash.com/photo-1504384308090-c894fdcc538d?q=80&w=2070&auto=format&fit=crop',
    category: 'Ticari'
  }
];

async function main() {
  console.log('Seeding projects...');
  for (const project of projects) {
    await prisma.project.upsert({
      where: { slug: project.slug },
      update: {},
      create: project,
    });
  }
  console.log('Seeding finished.');
}

main()
  .catch((e) => {
    console.error(e);
    process.exit(1);
  })
  .finally(async () => {
    await prisma.$disconnect();
    await pool.end();
  });
