INSERT INTO Role (role_name)
VALUES ('CLIENT'), ('ARTIST'), ('ADMIN');



INSERT INTO UserRole (user_id, role_id)
SELECT user_id, 1
FROM Users;

INSERT INTO UserRole (user_id, role_id)
SELECT user_id, 2
FROM ArtistProfile;

INSERT INTO UserRole (user_id, role_id)
SELECT user_id, 3
FROM Users
ORDER BY random()
LIMIT 5;



INSERT INTO Location (city, region, country)
VALUES
('Skopje','Skopje Region','MK'),
('Bitola','Pelagonia','MK'),
('Ohrid','Southwest','MK'),
('Tetovo','Polog','MK'),
('Prilep','Pelagonia','MK'),
('Kumanovo','Northeast','MK'),
('Strumica','Southeast','MK'),
('Veles','Vardar','MK'),
('Stip','East','MK'),
('Kavadarci','Vardar','MK'),
('Gostivar','Polog','MK'),
('Struga','Southwest','MK'),
('Kocani','East','MK'),
('Gevgelija','Southeast','MK'),
('Negotino','Vardar','MK'),
('Debar','Southwest','MK'),
('Kriva Palanka','Northeast','MK'),
('Radovis','Southeast','MK'),
('Berovo','East','MK'),
('Delcevo','East','MK'),
('Vinica','East','MK'),
('Probishtip','East','MK'),
('Krusevo','Pelagonia','MK'),
('Resen','Pelagonia','MK'),
('Sveti Nikole','Vardar','MK');



INSERT INTO Genre (genre_name)
VALUES
('Pop'),('Rock'),('Jazz'),('Hip Hop'),
('Techno'),('House'),('EDM'),
('Classical'),('Folk'),('R&B');



INSERT INTO ArtistType (type_name)
VALUES ('Solo'), ('Band'), ('DJ');

UPDATE ArtistType
SET description = CASE artist_type_id
    WHEN 1 THEN 'Individual solo music performer or singer.'
    WHEN 2 THEN 'Music group or band performing together.'
    WHEN 3 THEN 'DJ or electronic music performer.'
END;



INSERT INTO Users (email, password_hash,first_name, last_name, phone, account_status)
SELECT
    CASE

        WHEN cp.user_id IS NOT NULL THEN
            LOWER(replace(cp.display_name, ' ', '.'))
            || gs.i
            || '@mail.com'


        WHEN ap.user_id IS NOT NULL THEN
            LOWER(replace(ap.stage_name, ' ', '.'))
            || gs.i
            || '@mail.com'


        ELSE
            'user' || gs.i || '@mail.com'
    END,

    'hash',

    CASE

        WHEN cp.user_id IS NOT NULL THEN
            split_part(cp.display_name, ' ', 1)


        WHEN ap.user_id IS NOT NULL THEN
            split_part(ap.stage_name, ' ', 1)


        ELSE
            'User' || gs.i
    END,

    CASE

        WHEN cp.user_id IS NOT NULL THEN
            CASE
                WHEN strpos(cp.display_name, ' ') > 0
                THEN split_part(cp.display_name, ' ', 2)
                ELSE 'Client'
            END


        WHEN ap.user_id IS NOT NULL THEN
            CASE
                WHEN strpos(ap.stage_name, ' ') > 0
                THEN split_part(ap.stage_name, ' ', 2)
                ELSE 'Artist'
            END


        ELSE
            'Lastname_' || gs.i
    END,

    '07' || LPAD((floor(random()*10000000))::text, 7, '0'),

    CASE
        WHEN random() < 0.7 THEN 'ACTIVE'
        WHEN random() < 0.85 THEN 'INACTIVE'
        WHEN random() < 0.95 THEN 'SUSPENDED'
        ELSE 'PENDING'
    END

FROM generate_series(1, 10000) gs(i)

LEFT JOIN ClientProfile cp
    ON cp.user_id = gs.i

LEFT JOIN ArtistProfile ap
    ON ap.user_id = gs.i;




INSERT INTO VenueType (name, description)
VALUES
('Indoor', 'Closed indoor venue'),
('Outdoor', 'Open air venue'),
('Club', 'Nightclub or party venue'),
('Wedding Hall', 'Formal event venue');

INSERT INTO Venue (
  venue_type_id,
  location_id,
  venue_name,
  address,
  capacity,
  indoor_outdoor
)
SELECT
  (random()*3 + 1)::int,

  (SELECT location_id FROM Location ORDER BY random() LIMIT 1),

  'Venue_' || i,

  'Street ' || i || ', Center',

  (random()*500 + 50)::int,

  (ARRAY['INDOOR','OUTDOOR','MIXED'])[floor(random()*3)+1]

FROM generate_series(1, 200) s(i);

UPDATE Venue
SET
    venue_name =
        (ARRAY[
            'Arena Hall',
            'Sky Events',
            'Diamond Venue',
            'Elite Center',
            'Royal Palace',
            'Moonlight Hall',
            'Golden Event Center',
            'Galaxy Club',
            'VIP Lounge',
            'Sunset Venue',
            'Diamond Ballroom',
            'Crystal Palace',
            'Platinum Events',
            'Imperial Hall',
            'Central Venue',
            'City Stage',
            'Aura Center',
            'Infinity Hall',
            'Pulse Club',
            'Majestic Venue'
        ])[floor(random()*20)+1]
        || ' '
        || venue_id,

    address =
        (ARRAY[
            'Partizanska',
            'Ilindenska',
            'Makedonija',
            'Goce Delcev',
            'Jane Sandanski',
            'Marshal Tito',
            '11 Oktomvri',
            'Dimitar Vlahov',
            'Kej 13 Noemvri',
            'Bulevar Srbija',
            'Boris Trajkovski',
            'Nikola Tesla',
            'Pirinska',
            'Orce Nikolov',
            'Vodno',
            'ASNOM',
            'Krusevska Republika',
            'Prvomajska',
            'Balkan',
            'Industriska'
        ])[floor(random()*20)+1]
        || ' '
        || (floor(random()*200)+1)::int,

    location_id =
    CASE
        WHEN venue_id <= 60 THEN
            (ARRAY[1,1,1,1,2,2,3,4,5])[floor(random()*9)+1]

        WHEN venue_id <= 100 THEN
            (ARRAY[1,2,3,4,5,6,7,8,9])[floor(random()*9)+1]

        WHEN venue_id <= 150 THEN
            (ARRAY[6,7,8,9,10,11,12,13,14])[floor(random()*9)+1]

        ELSE
            (ARRAY[15,16,17,18,19,20,21,22,23,24,25])[floor(random()*11)+1]
    END;


INSERT INTO PerformanceDurationOption (label, duration_minutes)
VALUES
('30 min', 30),
('1 hour', 60),
('2 hours', 120),
('3 hours', 180),
('4 hours', 240);

INSERT INTO ClientProfile (user_id)
SELECT u.user_id
FROM Users u
LEFT JOIN ClientProfile c ON c.user_id = u.user_id
WHERE c.user_id IS NULL
LIMIT 5000;

UPDATE ClientProfile
SET
  display_name = 'Client_' || client_id,
  company_name = CASE
    WHEN random() < 0.3 THEN 'Company_' || client_id
    ELSE NULL
  END,
  preferred_contact_method =
    (ARRAY['EMAIL','PHONE','SMS'])[floor(random()*3)+1],
  location_id = (random()*4 + 1)::int
WHERE display_name IS NULL;


UPDATE ClientProfile
SET display_name =
CASE
    WHEN random() < 0.5 THEN

    (
        (ARRAY[
            'Aleksandar','Stefan','Marko','Nikola','Filip','Petar','Andrej','Martin','David','Dimitar',
            'Viktor','Luka','Kristijan','Ivan','Jovan','Matej','Daniel','Bojan','Goran','Dejan',
            'Milan','Igor','Nenad','Kiril','Oliver','Blagoj','Zoran','Dragan','Vladimir','Aleksa',
            'Antonio','Emil','Damjan','Mihail','Boris','Todor','Riste','Kosta','Veljko','Darko',
            'Branko','Sasho','Zharko','Gjorgji','Trajche','Stojan','Pero','Slobodan','Valentin','Ilija',
            'Bojan','Jakov','Teodor','Gorjan','Hristijan','Simen','Ognen','Bojidar','Kristian','Mite',
            'Vane','Cvetan','Goce','Pavle','Miroslav','Bane','Lazar','Stevche','Tomislav','Nikche',
            'Janko','Rade','Simeon','Petko','Dime','Kire','Jordan','Kalin','Vlatko','Zhivko',
            'Dushko','Tome','Blaze','Ljupcho','Vasko','Gligor','Spase','Nikodin','Aco','Ace',
            'Koco','Borce','Gligorche','Mitko','Kiril','Slave','Bobi','Marjan','Jole','Kiko'
        ])[floor(random()*100)+1]

        || ' ' ||

        (ARRAY[
            'Petrovski','Stojanovski','Nikolovski','Trajkovski','Jovanovski','Ilievski','Mitrevski','Ristovski','Georgievski','Kostovski',
            'Angelovski','Todorovski','Stefanovski','Mladenovski','Dimitrovski','Atanasovski','Markovski','Spasovski','Bogdanovski','Manasievski',
            'Velkovski','Temelkovski','Mihajlovski','Gligorovski','Tasevski','Janevski','Radevski','Petreski','Boshkovski','Chadikovski',
            'Mitevski','Bogoevski','Bojadzhiski','Kuzmanovski','Pandevski','Nestorovski','Talevski','Arsovski','Gjorgievski','Naumovski',
            'Donevski','Kitanovski','Rangelski','Shuklevski','Mickovski','Krstevski','Rupchevski','Popovski','Mucevski','Trpeski',
            'Dameski','Simjanovski','Dojchinovski','Kolevski','Mojsovski','Bojkovski','Klekovski','Stamenkovski','Bashovski','Vasilevski',
            'Toshevski','Risteski','Karanfilovski','Shapkaroski','Zafirovski','Jankuloski','Bogoeski','Madzharovski','Sazdovski','Veljanovski',
            'Belevski','Kotevski','Kochevski','Milevski','Tanushevski','Kjurkchievski','Maleski','Denkovski','Bimblovski','Klimovski',
            'Despotovski','Lazarovski','Hristovski','Cvetkovski','Pechijareski','Shterjovski','Dojkovski','Boshnevski','Kitanoski','Mickoski',
            'Bojchevski','Kiprijanovski','Vidanovski','Kjurchiski','Tosheski','Zdravevski','Shilegovski','Kondovski','Pavlovski','Rupovski'
        ])[floor(random()*100)+1]
    )

    ELSE

    (
        (ARRAY[
            'Marija','Ana','Elena','Ivana','Sara','Teodora','Simona','Monika','Mila','Jovana',
            'Kristina','Angela','Andrea','Viktorija','Katerina','Tamara','Magdalena','Matea','Iva','Stefani',
            'Biljana','Daniela','Gordana','Aleksandra','Natasha','Veronika','Marina','Anastasija','Ljupka','Sanja',
            'Emilija','Maja','Valentina','Nina','Ema','Lidija','Dragana','Milica','Isidora','Sofija',
            'Petra','Leona','Barbara','Hana','Megi','Tea','Kalina','Vesna','Bojana','Karla',
            'Tatjana','Zorica','Jasmina','Slavica','Violeta','Klara','Angela','Rosica','Desanka','Jadranka',
            'Mirela','Ljubica','Snezhana','Olivera','Veselinka','Anita','Tijana','Nadica','Radmila','Silvana',
            'Renata','Blagica','Cvetanka','Mimoza','Menka','Zhaklina','Dushanka','Sonja','Biserka','Ruzhica',
            'Gorica','Stanislava','Kornelija','Mirjana','Margarita','Nela','Viktorina','Danijela','Marijana','Liljana',
            'Ganka','Makedonka','Bosilka','Vaska','Milena','Nada','Elizabeta','Vangelica','Vaska','Lenche'
        ])[floor(random()*100)+1]

        || ' ' ||

        (ARRAY[
            'Petrovska','Stojanovska','Nikolovska','Trajkovska','Jovanovska','Ilievska','Mitrevska','Ristovska','Georgievska','Kostovska',
            'Angelovska','Todorovska','Stefanovska','Mladenovska','Dimitrovska','Atanasovska','Markovska','Spasovska','Bogdanovska','Manasievska',
            'Velkovska','Temelkovska','Mihajlovska','Gligorovska','Tasevska','Janevska','Radevska','Petreska','Boshkovska','Chadikovska',
            'Mitevska','Bogoevska','Bojadzhiska','Kuzmanovska','Pandevska','Nestorovska','Talevska','Arsovska','Gjorgievska','Naumovska',
            'Donevska','Kitanovska','Rangelska','Shuklevska','Mickovska','Krstevska','Rupchevska','Popovska','Mucevska','Trpeska',
            'Dameska','Simjanovska','Dojchinovska','Kolevska','Mojsovska','Bojkovska','Klekovska','Stamenkovska','Bashovska','Vasilevska',
            'Toshevska','Risteska','Karanfilovska','Shapkaroska','Zafirovska','Jankuloska','Bogoeska','Madzharovska','Sazdovska','Veljanovska',
            'Belevska','Kotevska','Kochevska','Milevska','Tanushevska','Kjurkchievska','Maleska','Denkovska','Bimblovska','Klimovska',
            'Despotovska','Lazarovska','Hristovska','Cvetkovska','Pechijareska','Shterjovska','Dojkovska','Boshnevska','Kitanoska','Mickoska',
            'Bojchevska','Kiprijanovska','Vidanovska','Kjurchiska','Tosheska','Zdravevska','Shilegovska','Kondovska','Pavlovska','Rupovska'
        ])[floor(random()*100)+1]
    )
END;

UPDATE ClientProfile
SET company_name =
CASE
    WHEN random() < 0.35 THEN
        (ARRAY[
            'MK Events',
            'Balkan Weddings',
            'Elite Productions',
            'Vision Media',
            'Golden Moments',
            'Urban Events',
            'Diamond Entertainment',
            'Skopje Music Group',
            'Aura Productions',
            'Infinity Events',
            'Sunset Weddings',
            'Prestige Event Solutions',
            'Royal Moments',
            'Prime Entertainment',
            'Nova Event Group',
            'Dynamic Productions',
            'Art Media Studio',
            'Pulse Events',
            'Celebrity Booking',
            'Event Masters',
            'VIP Moments',
            'Music Factory',
            'Stage One',
            'Live Experience',
            'Future Sounds',
            'Creative Events',
            'Exclusive Weddings',
            'Dream Day Events',
            'Urban Nights',
            'Skyline Productions',
            'Balkan Stars',
            'Next Level Events',
            'Platinum Booking',
            'Starline Entertainment',
            'Galaxy Events',
            'Apollo Productions',
            'Harmony Weddings',
            'Blue Sky Events',
            'Visionary Group',
            'Spotlight Entertainment',
            'Magic Moments',
            'Elite Weddings',
            'Event Horizon',
            'Luna Productions',
            'Epic Events',
            'Infinity Booking',
            'Grand Stage',
            'Dynamic Nights',
            'Premium Events',
            'Crown Entertainment'
        ])[floor(random()*50)+1]

    ELSE NULL
END;


INSERT INTO Bookable (bookable_type, display_name, description, base_price_from, average_rating, location_id, is_active)
SELECT
  'ARTIST',
  'Artist_' || i,
  'Professional performer',
  (random()*300 + 50)::int,
  ROUND((random()*5)::numeric, 2),
  (random()*4 + 1)::int,
  TRUE
FROM generate_series(1, 500) s(i);

INSERT INTO Bookable (bookable_type, display_name, description, base_price_from, average_rating, location_id, is_active)
SELECT
  'BAND',
  'Band_' || i,
  'Live band for events',
  (random()*1000 + 300)::int,
  ROUND((random()*5)::numeric, 2),
  (random()*4 + 1)::int,
  TRUE
FROM generate_series(1, 100) s(i);

UPDATE Bookable b
SET display_name = ap.stage_name
FROM ArtistProfile ap
WHERE b.bookable_id = ap.bookable_id;

UPDATE Bookable b
SET display_name = bp.band_name
FROM BandProfile bp
WHERE b.bookable_id = bp.bookable_id;


INSERT INTO ArtistProfile (bookable_id, user_id, artist_type_id, stage_name, biography, is_verified)
SELECT
  b.bookable_id,
  u.user_id,
  (random()*2 + 1)::int,

  'Artist_' || b.bookable_id,

  (ARRAY[
    'Professional performer with years of experience.',
    'Energetic and passionate about live music.',
    'Available for weddings, parties and events.',
    'Experienced in international performances.',
    'Known for engaging the audience.'
  ])[floor(random()*5)+1],

  CASE WHEN random() < 0.3 THEN TRUE ELSE FALSE END

FROM
  (SELECT bookable_id FROM Bookable LIMIT 500) b
JOIN
  (SELECT user_id FROM Users LIMIT 500) u
ON b.bookable_id = u.user_id;


WITH solo_names AS (
    SELECT ROW_NUMBER() OVER () AS rn, name
    FROM (
        VALUES
        ('Taylor Swift'),
        ('Drake'),
        ('The Weeknd'),
        ('Ed Sheeran'),
        ('Adele'),
        ('Eminem'),
        ('Rihanna'),
        ('Beyoncé'),
        ('Justin Bieber'),
        ('Bruno Mars'),
        ('Ariana Grande'),
        ('Billie Eilish'),
        ('Olivia Rodrigo'),
        ('Dua Lipa'),
        ('Harry Styles'),
        ('Post Malone'),
        ('Kendrick Lamar'),
        ('J. Cole'),
        ('Travis Scott'),
        ('Future'),
        ('SZA'),
        ('Doja Cat'),
        ('Nicki Minaj'),
        ('Cardi B'),
        ('Megan Thee Stallion'),
        ('Selena Gomez'),
        ('Miley Cyrus'),
        ('Katy Perry'),
        ('Lady Gaga'),
        ('Shawn Mendes'),
        ('Camila Cabello'),
        ('Charlie Puth'),
        ('Sam Smith'),
        ('Lewis Capaldi'),
        ('Halsey'),
        ('Lana Del Rey'),
        ('Lorde'),
        ('Chris Brown'),
        ('Usher'),
        ('Alicia Keys'),
        ('John Legend'),
        ('Jason Derulo'),
        ('Pitbull'),
        ('Flo Rida'),
        ('Akon'),
        ('Sean Paul'),
        ('Timbaland'),
        ('Pharrell Williams'),
        ('Macklemore'),
        ('Wiz Khalifa'),
        ('Tyga'),
        ('Playboi Carti'),
        ('Lil Uzi Vert'),
        ('Young Thug'),
        ('Gunna'),
        ('Roddy Ricch'),
        ('Polo G'),
        ('Juice WRLD'),
        ('XXXTentacion'),
        ('Pop Smoke'),
        ('Lil Durk'),
        ('Logic'),
        ('NF'),
        ('Machine Gun Kelly'),
        ('G-Eazy'),
        ('Jack Harlow'),
        ('Latto'),
        ('Ice Spice'),
        ('Central Cee'),
        ('Stormzy'),
        ('Dave'),
        ('Skepta'),
        ('Fred again..'),
        ('Raye'),
        ('Jessie J'),
        ('Conan Gray'),
        ('Tate McRae'),
        ('JVKE'),
        ('Lizzo'),
        ('Pink'),
        ('Kelly Clarkson'),
        ('Demi Lovato'),
        ('Christina Aguilera'),
        ('Jennifer Lopez'),
        ('Fergie'),
        ('Gwen Stefani'),
        ('Nelly Furtado'),
        ('Robin Thicke'),
        ('Childish Gambino'),
        ('Anderson .Paak'),
        ('Tyler The Creator'),
        ('Frank Ocean'),
        ('Daniel Caesar'),
        ('Giveon'),
        ('Khalid'),
        ('Bryson Tiller'),
        ('Tory Lanez'),
        ('Summer Walker'),
        ('Kehlani'),
        ('Jhene Aiko'),
        ('Tems'),
        ('Burna Boy'),
        ('Wizkid'),
        ('Davido'),
        ('Ayra Starr'),
        ('Rema'),
        ('CKay'),
        ('Stromae'),
        ('Indila'),
        ('Zaz'),
        ('Aya Nakamura'),
        ('David Bowie'),
        ('George Michael'),
        ('Phil Collins'),
        ('Sting'),
        ('Bryan Adams'),
        ('Rod Stewart'),
        ('Tom Jones'),
        ('Andrea Bocelli'),
        ('Josh Groban'),
        ('Sarah Brightman'),
        ('Enya'),
        ('Yanni'),
        ('Joji'),
        ('Rich Brian'),
        ('NIKI'),
        ('Keshi'),
        ('Zucchero'),
        ('Eros Ramazzotti'),
        ('Laura Pausini'),
        ('Tiziano Ferro'),
        ('Loreen'),
        ('Sia'),
        ('Gotye'),
        ('Tones And I'),
        ('Keith Urban'),
        ('Luke Combs'),
        ('Morgan Wallen'),
        ('Chris Stapleton'),
        ('Carrie Underwood')
    ) AS t(name)
),
solo_artists AS (
    SELECT artist_id,
           ROW_NUMBER() OVER (ORDER BY artist_id) AS rn
    FROM ArtistProfile
    WHERE artist_type_id = 1
)
UPDATE ArtistProfile ap
SET stage_name = sn.name
FROM solo_artists sa
JOIN solo_names sn ON sa.rn = sn.rn
WHERE ap.artist_id = sa.artist_id;

WITH band_names AS (
    SELECT ROW_NUMBER() OVER () AS rn, name
    FROM (
        VALUES
        ('Coldplay'),
        ('Imagine Dragons'),
        ('Maroon 5'),
        ('OneRepublic'),
        ('Linkin Park'),
        ('Green Day'),
        ('Fall Out Boy'),
        ('Paramore'),
        ('Panic! At The Disco'),
        ('Red Hot Chili Peppers'),
        ('Metallica'),
        ('Slipknot'),
        ('Iron Maiden'),
        ('Black Sabbath'),
        ('AC/DC'),
        ('Queen'),
        ('The Beatles'),
        ('The Rolling Stones'),
        ('Pink Floyd'),
        ('Led Zeppelin'),
        ('Nirvana'),
        ('Pearl Jam'),
        ('Foo Fighters'),
        ('Arctic Monkeys'),
        ('The Killers'),
        ('Muse'),
        ('Radiohead'),
        ('Blur'),
        ('Oasis'),
        ('U2'),
        ('Bon Jovi'),
        ('Journey'),
        ('Aerosmith'),
        ('Guns N Roses'),
        ('Def Leppard'),
        ('Van Halen'),
        ('Kiss'),
        ('Eagles'),
        ('Fleetwood Mac'),
        ('ABBA'),
        ('Bee Gees'),
        ('Earth Wind & Fire'),
        ('Black Eyed Peas'),
        ('Chainsmokers'),
        ('BTS'),
        ('BLACKPINK'),
        ('EXO'),
        ('TWICE'),
        ('Stray Kids'),
        ('SEVENTEEN'),
        ('NewJeans'),
        ('LE SSERAFIM'),
        ('IVE'),
        ('TXT'),
        ('ENHYPEN'),
        ('BigBang'),
        ('Girls Generation'),
        ('Super Junior'),
        ('2NE1'),
        ('Aventura'),
        ('Wisin & Yandel'),
        ('Wu-Tang Clan'),
        ('Run DMC'),
        ('Public Enemy'),
        ('Migos'),
        ('Little Mix'),
        ('One Direction'),
        ('Westlife'),
        ('Backstreet Boys'),
        ('NSYNC'),
        ('Jonas Brothers'),
        ('The Script'),
        ('Keane'),
        ('Snow Patrol'),
        ('Thirty Seconds To Mars'),
        ('Simple Plan'),
        ('Good Charlotte'),
        ('Sum 41'),
        ('Blink-182'),
        ('My Chemical Romance'),
        ('The Offspring'),
        ('Deep Purple'),
        ('Scorpions'),
        ('Rammstein'),
        ('Nightwish'),
        ('Sabaton'),
        ('Ghost'),
        ('Disturbed'),
        ('System Of A Down'),
        ('Korn'),
        ('Bring Me The Horizon'),
        ('Five Finger Death Punch'),
        ('Avenged Sevenfold'),
        ('Bullet For My Valentine'),
        ('Papa Roach'),
        ('Evanescence'),
        ('Within Temptation'),
        ('Limp Bizkit'),
        ('Deftones'),
        ('Megadeth'),
        ('Slayer'),
        ('Cannibal Corpse'),
        ('Behemoth'),
        ('Cradle Of Filth'),
        ('Children Of Bodom'),
        ('Opeth'),
        ('Dream Theater'),
        ('Tool'),
        ('Porcupine Tree'),
        ('Genesis'),
        ('Yes'),
        ('King Crimson'),
        ('Rush'),
        ('The Doors'),
        ('The Police'),
        ('The Cure'),
        ('Depeche Mode'),
        ('Talking Heads'),
        ('The Smiths'),
        ('Joy Division'),
        ('New Order'),
        ('Jamiroquai'),
        ('Tame Impala'),
        ('Glass Animals'),
        ('The 1975'),
        ('Phoenix'),
        ('Franz Ferdinand'),
        ('MGMT'),
        ('Empire Of The Sun'),
        ('Gorillaz'),
        ('BABYMETAL'),
        ('X Japan'),
        ('ONE OK ROCK'),
        ('Official HIGE DANdism'),
        ('YOASOBI'),
        ('RADWIMPS'),
        ('King Gnu'),
        ('Perfume'),
        ('Maneskin'),
        ('Il Volo'),
        ('ABBA'),
        ('Roxette'),
        ('A-ha'),
        ('The Cranberries'),
        ('Enigma'),
        ('Modern Talking'),
        ('Boney M'),
        ('Europe'),
        ('Alphaville'),
        ('Ace Of Base'),
        ('INXS'),
        ('Crowded House'),
        ('Men At Work'),
        ('Savage Garden'),
        ('Florida Georgia Line'),
        ('Dan + Shay'),
        ('The Beach Boys'),
        ('Simon & Garfunkel'),
        ('The Who'),
        ('Cream'),
        ('Santana'),
        ('Chicago'),
        ('Boston'),
        ('Foreigner'),
        ('REO Speedwagon'),
        ('Lynyrd Skynyrd'),
        ('The White Stripes'),
        ('Queens Of The Stone Age'),
        ('Interpol'),
        ('The Strokes'),
        ('The Libertines'),
        ('Kasabian'),
        ('Bloc Party'),
        ('The Kooks'),
        ('Two Door Cinema Club'),
        ('Vampire Weekend'),
        ('Foster The People'),
        ('Alt-J'),
        ('Bon Iver'),
        ('The National'),
        ('Mumford & Sons'),
        ('Of Monsters And Men'),
        ('The Lumineers'),
        ('Train'),
        ('Lifehouse'),
        ('The Fray'),
        ('Daughtry'),
        ('Nickelback'),
        ('Creed'),
        ('Stone Sour'),
        ('Seether'),
        ('Breaking Benjamin'),
        ('Three Days Grace'),
        ('Skillet'),
        ('Starset'),
        ('Sleep Token'),
        ('Bad Omens'),
        ('Spiritbox'),
        ('Motionless In White'),
        ('Architects'),
        ('I Prevail'),
        ('Pierce The Veil'),
        ('Sleeping With Sirens'),
        ('Asking Alexandria'),
        ('Falling In Reverse'),
        ('Clean Bandit'),
        ('Rudimental'),
        ('Disclosure'),
        ('Above & Beyond'),
        ('Major Lazer'),
        ('Meduza'),
        ('Tale Of Us'),
        ('The xx'),
        ('Justice'),
        ('Pendulum'),
        ('Knife Party'),
        ('The Chainsmokers'),
        ('Daft Punk'),
        ('Swedish House Mafia'),
        ('The Chemical Brothers'),
        ('Underworld'),
        ('Massive Attack'),
        ('Portishead'),
        ('Zero 7'),
        ('Air'),
        ('M83'),
        ('Sigur Ros'),
        ('Explosions In The Sky'),
        ('God Is An Astronaut'),
        ('Khruangbin'),
        ('Parcels'),
        ('LANY'),
        ('Walk The Moon'),
        ('Bastille'),
        ('X Ambassadors'),
        ('American Authors'),
        ('fun.'),
        ('Fitz And The Tantrums'),
        ('Years & Years'),
        ('Why Dont We'),
        ('CNCO'),
        ('Boyz II Men'),
        ('Destinys Child'),
        ('TLC'),
        ('En Vogue'),
        ('The Pussycat Dolls'),
        ('Atomic Kitten'),
        ('All Saints'),
        ('Sugababes'),
        ('Blue')
    ) AS t(name)
),
band_artists AS (
    SELECT artist_id,
           ROW_NUMBER() OVER (ORDER BY artist_id) AS rn
    FROM ArtistProfile
    WHERE artist_type_id = 2
)
UPDATE ArtistProfile ap
SET stage_name = bn.name
FROM band_artists ba
JOIN band_names bn ON ba.rn = bn.rn
WHERE ap.artist_id = ba.artist_id;

WITH dj_names AS (
    SELECT ROW_NUMBER() OVER () AS rn, name
    FROM (
        VALUES
        ('David Guetta'),
        ('Martin Garrix'),
        ('Tiësto'),
        ('Avicii'),
        ('Alan Walker'),
        ('Kygo'),
        ('Diplo'),
        ('Skrillex'),
        ('Zedd'),
        ('Marshmello'),
        ('Steve Aoki'),
        ('DJ Snake'),
        ('Calvin Harris'),
        ('Swedish House Mafia'),
        ('Daft Punk'),
        ('Armin van Buuren'),
        ('Hardwell'),
        ('Don Diablo'),
        ('Alesso'),
        ('Afrojack'),
        ('KSHMR'),
        ('Nicky Romero'),
        ('Deadmau5'),
        ('Porter Robinson'),
        ('Eric Prydz'),
        ('Paul van Dyk'),
        ('Fisher'),
        ('Vintage Culture'),
        ('CamelPhat'),
        ('Black Coffee'),
        ('Peggy Gou'),
        ('Charlotte de Witte'),
        ('Amelie Lens'),
        ('Carl Cox'),
        ('Adam Beyer'),
        ('Solomun'),
        ('Boris Brejcha'),
        ('Claptone'),
        ('Anyma'),
        ('Meduza'),
        ('Purple Disco Machine'),
        ('Sigala'),
        ('Joel Corry'),
        ('Above & Beyond'),
        ('Disclosure'),
        ('Clean Bandit'),
        ('Rudimental'),
        ('The Chainsmokers'),
        ('Major Lazer'),
        ('Knife Party'),
        ('The Chemical Brothers'),
        ('Underworld'),
        ('Justice'),
        ('Moby'),
        ('Fatboy Slim'),
        ('Paul Oakenfold'),
        ('ATB'),
        ('Benny Benassi'),
        ('Robin Schulz'),
        ('Lost Frequencies'),
        ('Tujamo'),
        ('Timmy Trumpet'),
        ('W&W'),
        ('VINAI'),
        ('R3HAB'),
        ('Blasterjaxx'),
        ('Dimitri Vegas'),
        ('Like Mike'),
        ('Basshunter'),
        ('Gareth Emery'),
        ('Cosmic Gate'),
        ('Andrew Rayel'),
        ('Vini Vici'),
        ('Infected Mushroom'),
        ('Astrix'),
        ('Borgore'),
        ('Yellow Claw'),
        ('Baauer'),
        ('RL Grime'),
        ('Flume'),
        ('Illenium'),
        ('Seven Lions'),
        ('San Holo'),
        ('ODESZA'),
        ('Rezz'),
        ('Malaa'),
        ('Tchami'),
        ('Kungs'),
        ('Cedric Gervais'),
        ('Sam Feldt'),
        ('Alle Farben'),
        ('Ofenbach'),
        ('Topic'),
        ('Regard'),
        ('Dynoro'),
        ('Steve Angello'),
        ('Sebastian Ingrosso'),
        ('Axwell'),
        ('Maceo Plex'),
        ('Nina Kraviz'),
        ('Richie Hawtin'),
        ('Nicole Moudaber'),
        ('Deborah De Luca'),
        ('ANNA'),
        ('Tale Of Us'),
        ('ARTBAT'),
        ('Adriatique'),
        ('Miss Monique'),
        ('Morten'),
        ('Laidback Luke'),
        ('Fedde Le Grand'),
        ('Oliver Heldens'),
        ('Lucas & Steve'),
        ('Mike Williams'),
        ('Brooks'),
        ('Julian Jordan'),
        ('Sander van Doorn'),
        ('Headhunterz'),
        ('Wildstylez'),
        ('Da Tweekaz'),
        ('Sub Zero Project'),
        ('Coone'),
        ('Angerfist')
    ) AS t(name)
),
dj_artists AS (
    SELECT artist_id,
           ROW_NUMBER() OVER (ORDER BY artist_id) AS rn
    FROM ArtistProfile
    WHERE artist_type_id = 3
)
UPDATE ArtistProfile ap
SET stage_name = dn.name
FROM dj_artists da
JOIN dj_names dn ON da.rn = dn.rn
WHERE ap.artist_id = da.artist_id;



INSERT INTO BandProfile (bookable_id, owner_user_id, band_name, formation_year, biography)
SELECT
  b.bookable_id,
  (random()*10000 + 1)::int,

  'Band_' || b.bookable_id,

  (2000 + (random()*24)::int),

  (ARRAY[
    'Dynamic band performing live events.',
    'Experienced group with international gigs.',
    'Energetic band for weddings and parties.',
    'Versatile band covering multiple genres.'
  ])[floor(random()*4)+1]

FROM (
  SELECT bookable_id
  FROM Bookable
  WHERE bookable_id > 500
  LIMIT 100
) b;

WITH band_names AS (
    SELECT ROW_NUMBER() OVER () AS rn, name
    FROM (
        VALUES
        ('Coldplay'),
        ('Imagine Dragons'),
        ('Maroon 5'),
        ('OneRepublic'),
        ('Linkin Park'),
        ('Green Day'),
        ('Fall Out Boy'),
        ('Paramore'),
        ('Panic! At The Disco'),
        ('Red Hot Chili Peppers'),
        ('Metallica'),
        ('Slipknot'),
        ('Iron Maiden'),
        ('Black Sabbath'),
        ('AC/DC'),
        ('Queen'),
        ('The Beatles'),
        ('The Rolling Stones'),
        ('Pink Floyd'),
        ('Led Zeppelin'),
        ('Nirvana'),
        ('Pearl Jam'),
        ('Foo Fighters'),
        ('Arctic Monkeys'),
        ('The Killers'),
        ('Muse'),
        ('Radiohead'),
        ('Blur'),
        ('Oasis'),
        ('U2'),
        ('Bon Jovi'),
        ('Journey'),
        ('Aerosmith'),
        ('Guns N Roses'),
        ('Def Leppard'),
        ('Van Halen'),
        ('Kiss'),
        ('Eagles'),
        ('Fleetwood Mac'),
        ('ABBA'),
        ('Bee Gees'),
        ('Earth Wind & Fire'),
        ('Black Eyed Peas'),
        ('Chainsmokers'),
        ('BTS'),
        ('BLACKPINK'),
        ('EXO'),
        ('TWICE'),
        ('Stray Kids'),
        ('SEVENTEEN'),
        ('NewJeans'),
        ('LE SSERAFIM'),
        ('IVE'),
        ('TXT'),
        ('ENHYPEN'),
        ('BigBang'),
        ('Girls Generation'),
        ('Super Junior'),
        ('2NE1'),
        ('Aventura'),
        ('Wisin & Yandel'),
        ('Wu-Tang Clan'),
        ('Run DMC'),
        ('Public Enemy'),
        ('Migos'),
        ('Little Mix'),
        ('One Direction'),
        ('Westlife'),
        ('Backstreet Boys'),
        ('NSYNC'),
        ('Jonas Brothers'),
        ('The Script'),
        ('Keane'),
        ('Snow Patrol'),
        ('Thirty Seconds To Mars'),
        ('Simple Plan'),
        ('Good Charlotte'),
        ('Sum 41'),
        ('Blink-182'),
        ('My Chemical Romance'),
        ('The Offspring'),
        ('Deep Purple'),
        ('Scorpions'),
        ('Rammstein'),
        ('Nightwish'),
        ('Sabaton'),
        ('Ghost'),
        ('Disturbed'),
        ('System Of A Down'),
        ('Korn'),
        ('Bring Me The Horizon'),
        ('Five Finger Death Punch'),
        ('Avenged Sevenfold'),
        ('Bullet For My Valentine'),
        ('Papa Roach'),
        ('Evanescence'),
        ('Within Temptation'),
        ('Limp Bizkit'),
        ('Deftones'),
        ('Megadeth')
    ) AS t(name)
),
bands AS (
    SELECT band_id,
           ROW_NUMBER() OVER (ORDER BY band_id) AS rn
    FROM BandProfile
    LIMIT 100
)
UPDATE BandProfile bp
SET band_name = bn.name
FROM bands b
JOIN band_names bn ON b.rn = bn.rn
WHERE bp.band_id = b.band_id;

INSERT INTO BandMember (band_id, artist_id)
SELECT
  b.band_id,
  a.artist_id
FROM BandProfile b
JOIN LATERAL (
  SELECT artist_id
  FROM ArtistProfile
  ORDER BY random() + b.band_id
  LIMIT (2 + floor(random()*3))::int
) a ON true;


INSERT INTO BookableGenre (bookable_id, genre_id)
SELECT
  b.bookable_id,
  g.genre_id
FROM Bookable b
JOIN LATERAL (
  SELECT genre_id
  FROM Genre
  ORDER BY random()
  LIMIT (2 + floor(random()*2))::int
) g ON true;


INSERT INTO BookingRequest (client_id, duration_id, event_type, event_date)
SELECT
  c.client_id,

  (random()*4 + 1)::int,

  (ARRAY['Wedding','Birthday','Corporate','Party'])[floor(random()*4)+1],

  CURRENT_DATE + (floor(random()*365))::int

FROM generate_series(1, 10000000)
JOIN LATERAL (
  SELECT client_id FROM ClientProfile ORDER BY random() LIMIT 1
) c ON true;

UPDATE BookingRequest br
SET
    venue_id = random_venue.venue_id,
    venue_type_id = random_venue.venue_type_id,
    location_id = random_venue.location_id
FROM LATERAL (
    SELECT
        v.venue_id,
        v.venue_type_id,
        v.location_id
    FROM Venue v
    WHERE v.venue_id =
        (
            floor(random() * (SELECT MAX(venue_id) FROM Venue) + 1)
        )::int
) random_venue;


INSERT INTO BookingStatusHistory (booking_id, changed_by_user_id, new_status, changed_at)
SELECT
  b.booking_id,
  (random()*999 + 1)::int,
  'CREATED',
  b.created_at
FROM Booking b;

INSERT INTO BookingStatusHistory (booking_id, changed_by_user_id, new_status, changed_at)
SELECT
  b.booking_id,
  (random()*999 + 1)::int,
  'CONFIRMED',
  b.created_at + INTERVAL '1 hour'
FROM Booking b
WHERE random() < 0.7;

INSERT INTO BookingStatusHistory (booking_id, changed_by_user_id, new_status, changed_at)
SELECT
  b.booking_id,
  (random()*999 + 1)::int,
  'COMPLETED',
  b.created_at + INTERVAL '2 hours'
FROM Booking b
WHERE random() < 0.5;



INSERT INTO Offer (request_id, bookable_id, duration_id, total_price)
SELECT
  r.request_id,
  b.bookable_id,
  (random()*5 + 1)::int,
  (random()*900 + 100)::int
FROM BookingRequest r
CROSS JOIN generate_series(1, 2)
JOIN LATERAL (
  SELECT bookable_id FROM Bookable ORDER BY random() LIMIT 1
) b ON true
WHERE r.request_id BETWEEN 1 AND 20000000;


INSERT INTO Booking (offer_id, final_price, booking_status, created_at)
SELECT
    o.offer_id,
    o.total_price,

    CASE
        WHEN rand_val < 0.6 THEN 'CREATED'
        WHEN rand_val < 0.85 THEN 'CONFIRMED'
        ELSE 'COMPLETED'
    END,

    CURRENT_TIMESTAMP - (floor(random()*30)::int * INTERVAL '1 day')

FROM (
    SELECT
        o.*,
        random() AS rand_val
    FROM Offer o
) o
WHERE rand_val < 0.2;

INSERT INTO Payment (booking_id, amount, payment_status)
SELECT
  b.booking_id,
  b.final_price,
  CASE
    WHEN b.booking_status = 'COMPLETED' THEN 'PAID'
    WHEN b.booking_status = 'CONFIRMED' THEN 'PAID'
    ELSE 'PENDING'
  END
FROM Booking b;

INSERT INTO Message (sender_user_id, receiver_user_id, request_id, booking_id, content, sent_at)
SELECT
  (random()*10000 + 1)::int,
  (random()*10000 + 1)::int,

  CASE
    WHEN random() < 0.5 THEN r.request_id
    ELSE NULL
  END,

  CASE
    WHEN random() >= 0.5 THEN b.booking_id
    ELSE NULL
  END,

  (ARRAY[
    'Hello, I want to book',
    'Is this date available?',
    'Can we change the time?',
    'Thank you for the offer',
    'Let’s confirm the booking',
    'Price seems good',
    'Can you send details?',
    'Looking forward to event'
  ])[floor(random()*8)+1],

  NOW() - (random() * INTERVAL '30 days')

FROM generate_series(1, 1000000) gs
LEFT JOIN LATERAL (
  SELECT request_id FROM BookingRequest ORDER BY random() LIMIT 1
) r ON true
LEFT JOIN LATERAL (
  SELECT booking_id FROM Booking ORDER BY random() LIMIT 1
) b ON true;


INSERT INTO AvailabilitySlot (bookable_id, start_datetime, end_datetime, status)
SELECT
  b.bookable_id,
  NOW(),
  NOW() + INTERVAL '2 hours',
  'AVAILABLE'
FROM generate_series(1, 600000)
JOIN LATERAL (
  SELECT bookable_id FROM Bookable ORDER BY random() LIMIT 1
) b ON true;

UPDATE AvailabilitySlot
SET
    bookable_id = ((random() * 599)::int + 1),

    start_datetime = random_start,

    end_datetime = random_start
        + (
            (ARRAY[1,2,3,4,5])[floor(random()*5)+1]
            * interval '1 hour'
        ),

    status = (
        ARRAY['AVAILABLE', 'BOOKED', 'PENDING']
    )[floor(random()*3)+1]

FROM (
    SELECT
        slot_id,

        NOW()
        + (random() * interval '180 days')
        + ((floor(random()*18) + 6) * interval '1 hour')
        AS random_start

    FROM AvailabilitySlot
) t

WHERE AvailabilitySlot.slot_id = t.slot_id;


INSERT INTO PricingRule (bookable_id, duration_id, venue_type_id, base_price)
SELECT
  b.bookable_id,

  d.duration_id,

  CASE
    WHEN random() < 0.5 THEN (random()*4 + 1)::int
    ELSE NULL
  END,

  ROUND((random()*500 + 100)::numeric, 2)

FROM Bookable b
JOIN LATERAL (
  SELECT duration_id
  FROM PerformanceDurationOption
  ORDER BY random()
  LIMIT (2 + floor(random()*2))::int
) d ON true;

UPDATE PricingRule
SET valid_to =
    valid_from + (
        (floor(random() * 365) + 30)::int
        * INTERVAL '1 day'
    );



INSERT INTO Review (booking_id, rating, comment)
SELECT
  b.booking_id,
  (floor(random()*5) + 1)::int,
  'Great experience'
FROM Booking b
WHERE b.booking_status = 'COMPLETED';



