import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();

async function main() {
  console.log('🌱 Seeding database...');

  // Clear existing data
  await prisma.album.deleteMany();

  // Create test albums
  const albums = [
    {
      title: 'Midnight Dreams',
      artist: 'Luna & The Sounds',
      article: 'A mesmerizing journey through electronic soundscapes that captures the essence of late-night contemplation. This album blends ambient textures with rhythmic pulses.',
      imageUrl: 'https://images.unsplash.com/photo-1470225620780-dba8ba36b745?w=300&h=300&fit=crop',
      spotifyLink: 'https://open.spotify.com/album/3OvN1z1j2345',
      genres: JSON.stringify(['Electronic', 'Ambient', 'Chill']),
      releaseDate: new Date('2024-03-15'),
      status: 'published',
      displayOrder: 1
    },
    {
      title: 'Urban Echoes',
      artist: 'The Neon Collective',
      article: 'Street poetry meets smooth jazz in this groundbreaking urban album. A fusion of hip-hop beats and jazz improvisation.',
      imageUrl: 'https://images.unsplash.com/photo-1493225457124-a3eb161ffa5f?w=300&h=300&fit=crop',
      spotifyLink: 'https://open.spotify.com/album/2XbK8h9i5678',
      genres: JSON.stringify(['Hip-Hop', 'Jazz']),
      releaseDate: new Date('2024-02-28'),
      status: 'published',
      displayOrder: 2
    },
    {
      title: 'Acoustic Sessions',
      artist: 'Emma Rivers',
      article: 'Raw and intimate acoustic performances recorded in a single take. Pure emotion captured in every strum.',
      imageUrl: 'https://images.unsplash.com/photo-1459749411175-04bf5292ceea?w=300&h=300&fit=crop',
      spotifyLink: '',
      genres: JSON.stringify(['Folk', 'Indie']),
      releaseDate: new Date('2024-04-10'),
      status: 'draft',
      displayOrder: 3
    },
    {
      title: 'Synthwave Nights',
      artist: 'Retro Vision',
      article: 'A nostalgic trip to the 80s with modern production techniques. Synthesizers and drum machines create a sonic time machine.',
      imageUrl: 'https://images.unsplash.com/photo-1511379938547-c1f69419868d?w=300&h=300&fit=crop',
      spotifyLink: 'https://open.spotify.com/album/9ZmP3k8l9012',
      genres: JSON.stringify(['Synthwave', 'Electronic']),
      releaseDate: new Date('2024-01-20'),
      status: 'published',
      displayOrder: 4
    },
    {
      title: 'Classical Reimagined',
      artist: 'Modern Orchestra',
      article: 'Timeless classical pieces performed with a contemporary twist. Where tradition meets innovation.',
      imageUrl: 'https://images.unsplash.com/photo-1514320291840-2e0a9bf2a9ae?w=300&h=300&fit=crop',
      spotifyLink: '',
      genres: JSON.stringify(['Classical', 'Contemporary']),
      releaseDate: new Date('2024-05-01'),
      status: 'draft',
      displayOrder: 5
    },
    {
      title: 'Desert Blues',
      artist: 'Sahara Collective',
      article: 'Blues from the heart of the desert, mixing traditional African rhythms with American blues.',
      imageUrl: 'https://images.unsplash.com/photo-1511671782779-c97d3d27a1d4?w=300&h=300&fit=crop',
      spotifyLink: 'https://open.spotify.com/album/4FmP5k7l8901',
      genres: JSON.stringify(['Blues', 'World Music', 'Folk']),
      releaseDate: new Date('2024-06-15'),
      status: 'published',
      displayOrder: 6
    },
    {
      title: 'Electric Waves',
      artist: 'Voltage Dreams',
      article: 'High-energy electronic music that pulses with life and creativity.',
      imageUrl: 'https://images.unsplash.com/photo-1571330735066-03aaa9429d89?w=300&h=300&fit=crop',
      spotifyLink: 'https://open.spotify.com/album/7GnP6k9m3456',
      genres: JSON.stringify(['Electronic', 'House', 'Techno']),
      releaseDate: new Date('2024-07-22'),
      status: 'published',
      displayOrder: 7
    },
    {
      title: 'Quiet Moments',
      artist: 'Sarah Chen',
      article: 'Peaceful piano compositions for reflection and relaxation.',
      imageUrl: 'https://images.unsplash.com/photo-1520523839897-bd0b52f945a0?w=300&h=300&fit=crop',
      spotifyLink: '',
      genres: JSON.stringify(['Classical', 'Ambient', 'Piano']),
      releaseDate: new Date('2024-08-30'),
      status: 'archived',
      displayOrder: 8
    }
  ];

  for (const album of albums) {
    await prisma.album.create({
      data: album
    });
  }

  console.log('✅ Database seeded successfully!');
  console.log(`📀 Created ${albums.length} albums`);
}

main()
  .catch((e) => {
    console.error('❌ Error seeding database:', e);
    process.exit(1);
  })
  .finally(async () => {
    await prisma.$disconnect();
  });
