
CREATE TABLE admins(
  id INT AUTO_INCREMENT PRIMARY KEY,
  email VARCHAR(190) UNIQUE NOT NULL,
  password_hash VARCHAR(255) NOT NULL,
  status ENUM('active','banned') DEFAULT 'active',
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE profiles(
  id INT AUTO_INCREMENT PRIMARY KEY,
  display_name VARCHAR(120) NOT NULL,
  slug VARCHAR(150) UNIQUE NOT NULL,
  age TINYINT NULL,
  city VARCHAR(120) NULL,
  about TEXT NULL,
  avatar VARCHAR(255) NULL,
  is_verified TINYINT(1) DEFAULT 0,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE ads(
  id INT AUTO_INCREMENT PRIMARY KEY,
  profile_id INT NOT NULL,
  title VARCHAR(200) NOT NULL,
  slug VARCHAR(220) NOT NULL UNIQUE,
  summary VARCHAR(300) NULL,
  description TEXT NULL,
  status ENUM('pending','active','paused','rejected') DEFAULT 'active',
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (profile_id) REFERENCES profiles(id)
);
CREATE TABLE placements(
  id INT AUTO_INCREMENT PRIMARY KEY,
  name ENUM('super','showcase','side','standard') NOT NULL,
  slot_limit TINYINT NOT NULL DEFAULT 10,
  is_active TINYINT(1) NOT NULL DEFAULT 1
);
CREATE TABLE placement_items(
  id INT AUTO_INCREMENT PRIMARY KEY,
  placement_id INT NOT NULL,
  ad_id INT NOT NULL,
  slot_no TINYINT NOT NULL,
  image VARCHAR(255) NULL,
  is_active TINYINT(1) NOT NULL DEFAULT 1,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  UNIQUE KEY uniq_slot (placement_id, slot_no),
  FOREIGN KEY (placement_id) REFERENCES placements(id),
  FOREIGN KEY (ad_id) REFERENCES ads(id)
);
