INSERT INTO "user_type" ("label") VALUES
  ('admin'),
  ('subscriber');

INSERT INTO "site" ("pce", "address_1", "address_2", "postal_code", "city") VALUES
  ('GI123456789', '12 Rue de la Paix',   NULL,     '75001', 'Paris'),
  ('GI987654321', '5 Avenue Foch',       'Bât B',  '69003', 'Lyon'),
  ('GI111222333', '8 Rue du Moulin',     NULL,     '59000', 'Lille'),
  ('GI444555666', '27 Boulevard Victor', 'Apt 12', '33000', 'Bordeaux');

-- Mots de passe d'exemple : (hash générés avec `mkpasswd --method=bcrypt --rounds=12 <mdp>`)
-- AdminPass123!
-- BobPass456!
-- ClairePass789!
-- DavidPass012

INSERT INTO "user" ("name", "first_name", "email", "password_hash", "user_type_id") VALUES
  ('Dupont',  'Alice',   'alice.dupont@example.com',   '$2b$12$qdHcvSLkbflmHn45gokjX.zm27JxamMBplA/l4y4D2GuykDvjJll.', (SELECT "user_type_id" FROM "user_type" WHERE "label" = 'admin')),
  ('Martin',  'Bernard', 'bernard.martin@example.com', '$2b$12$3ulCb.7b9LeQv2edkmju2uwtn8bA/1jpj4K5n51DxH6HYDme0Gbfq', (SELECT "user_type_id" FROM "user_type" WHERE "label" = 'subscriber')),
  ('Durand',  'Claire',  'claire.durand@example.com',  '$2b$12$nzYUQG/SHV9uvOxtYJ5XWOnUT1bgiUS0FejgFl.Y57Pz0LB9U5ia6', (SELECT "user_type_id" FROM "user_type" WHERE "label" = 'subscriber')),
  ('Leroy',   'David',   'david.leroy@example.com',    '$2b$12$Yy/K3.kghkrYtflPUGjuM.cj6pbCP/Bc4sasLlkbA7RgdlK1wzR2u', (SELECT "user_type_id" FROM "user_type" WHERE "label" = 'subscriber'));

INSERT INTO "subscription" ("site_id", "user_id") VALUES
  (
   (SELECT "site_id" FROM "site" WHERE "pce" = 'GI123456789'),
   (SELECT "user_id" FROM "user" WHERE "email" = 'bernard.martin@example.com')),

  (
   (SELECT "site_id" FROM "site" WHERE "pce" = 'GI987654321'),
   (SELECT "user_id" FROM "user" WHERE "email" = 'claire.durand@example.com')),

  (
   (SELECT "site_id" FROM "site" WHERE "pce" = 'GI111222333'),
   (SELECT "user_id" FROM "user" WHERE "email" = 'david.leroy@example.com')),

  ((SELECT "site_id" FROM "site" WHERE "pce" = 'GI444555666'),
   (SELECT "user_id" FROM "user" WHERE "email" = 'david.leroy@example.com'));

INSERT INTO "device" ("device_eui", "site_id")
VALUES (
    '0586fe41112d83d9',
    (SELECT "site_id" FROM "site" WHERE "pce" = 'GI123456789')
);