-- AppChat clean-install database
-- Version: 1.0.0
-- Import this single file into a new empty MySQL/MariaDB database.

-- AppChat complete backend schema for MySQL 8+/MariaDB 10.6+
CREATE DATABASE IF NOT EXISTS appchat_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE appchat_db;

CREATE TABLE IF NOT EXISTS users (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  username VARCHAR(64) UNIQUE,
  name VARCHAR(120) NOT NULL,
  email VARCHAR(190) UNIQUE NULL,
  password_hash VARCHAR(255) NULL,
  google_id VARCHAR(190) UNIQUE NULL,
  auth_token VARCHAR(255) NULL,
  pos TINYINT NOT NULL DEFAULT 3,
  role TINYINT NOT NULL DEFAULT 5,
  type TINYINT NOT NULL DEFAULT 1,
  state TINYINT NOT NULL DEFAULT 9,
  avatar VARCHAR(500) NULL,
  bg VARCHAR(500) NULL,
  theme VARCHAR(500) NULL,
  entry VARCHAR(500) NULL,
  profile_frame VARCHAR(500) NULL,
  comment VARCHAR(500) NULL,
  birthday VARCHAR(20) NULL,
  country VARCHAR(10) NULL,
  coins BIGINT NOT NULL DEFAULT 0,
  diamond BIGINT NOT NULL DEFAULT 0,
  dollar_earnings DECIMAL(18,8) NOT NULL DEFAULT 0,
  total_points BIGINT NOT NULL DEFAULT 0,
  gifter_points_total BIGINT NOT NULL DEFAULT 0,
  anchor_points_total BIGINT NOT NULL DEFAULT 0,
  recharge_points_total BIGINT NOT NULL DEFAULT 0,
  followers_count BIGINT NOT NULL DEFAULT 0,
  following_count BIGINT NOT NULL DEFAULT 0,
  posts_count BIGINT NOT NULL DEFAULT 0,
  gift_sent_count BIGINT NOT NULL DEFAULT 0,
  gift_received_count BIGINT NOT NULL DEFAULT 0,
  visiters_count BIGINT NOT NULL DEFAULT 0,
  view_count BIGINT NOT NULL DEFAULT 0,
  device_id VARCHAR(255) NULL,
  fcm_token TEXT NULL,
  language VARCHAR(10) DEFAULT 'en',
  web_token VARCHAR(128) NULL,
  online_rid BIGINT UNSIGNED DEFAULT 0,
  last_connected_at DATETIME NULL,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NULL,
  INDEX idx_users_state (state),
  INDEX idx_users_name (name),
  INDEX idx_users_device (device_id),
  INDEX idx_users_points (total_points),
  INDEX idx_users_followers (followers_count)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS user_tokens (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  uid BIGINT UNSIGNED NOT NULL,
  token CHAR(128) NOT NULL UNIQUE,
  device_id VARCHAR(255) NULL,
  platform VARCHAR(32) NULL,
  ip VARCHAR(64) NULL,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NULL,
  FOREIGN KEY (uid) REFERENCES users(id) ON DELETE CASCADE,
  INDEX idx_user_tokens_uid (uid),
  INDEX idx_user_tokens_device (device_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS levels (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  type VARCHAR(32) NOT NULL,
  lvl INT NOT NULL,
  points BIGINT NOT NULL DEFAULT 0,
  icon VARCHAR(500) NULL,
  privileges JSON NULL,
  created_at DATETIME NULL,
  UNIQUE KEY uq_levels_type_lvl (type, lvl)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS user_levels (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  uid BIGINT UNSIGNED NOT NULL,
  type VARCHAR(32) NOT NULL,
  lvl INT NOT NULL DEFAULT 0,
  points BIGINT NOT NULL DEFAULT 0,
  next_points BIGINT NOT NULL DEFAULT 0,
  icon VARCHAR(500) NULL,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NULL,
  UNIQUE KEY uq_user_levels (uid, type),
  FOREIGN KEY (uid) REFERENCES users(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS vip_packages (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  num INT NOT NULL,
  state TINYINT NOT NULL DEFAULT 9,
  icon VARCHAR(500) NULL,
  profile_frame VARCHAR(500) NULL,
  bg VARCHAR(500) NULL,
  entry_effect VARCHAR(500) NULL,
  name_entry_effect VARCHAR(500) NULL,
  frame VARCHAR(500) NULL,
  bubble VARCHAR(500) NULL,
  price BIGINT NOT NULL DEFAULT 0,
  renewal_price BIGINT NOT NULL DEFAULT 0,
  days INT NOT NULL DEFAULT 30,
  color VARCHAR(64) NULL,
  sort_order INT DEFAULT 0,
  created_at DATETIME NULL,
  updated_at DATETIME NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS vip_privileges (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  vip_id BIGINT UNSIGNED NOT NULL,
  shop_item VARCHAR(500) NULL,
  icon VARCHAR(500) NULL,
  state TINYINT NOT NULL DEFAULT 9,
  type INT NOT NULL,
  name VARCHAR(120) NOT NULL,
  sort_order INT DEFAULT 0,
  FOREIGN KEY (vip_id) REFERENCES vip_packages(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS user_vips (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  uid BIGINT UNSIGNED NOT NULL,
  vip_id BIGINT UNSIGNED NOT NULL,
  active TINYINT NOT NULL DEFAULT 1,
  state TINYINT NOT NULL DEFAULT 9,
  starts_at DATETIME NOT NULL,
  expires_at DATETIME NOT NULL,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NULL,
  FOREIGN KEY (uid) REFERENCES users(id) ON DELETE CASCADE,
  FOREIGN KEY (vip_id) REFERENCES vip_packages(id) ON DELETE CASCADE,
  INDEX idx_user_vips_active (uid, state, expires_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS store_items (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(120) NOT NULL,
  img VARCHAR(500) NULL,
  animation VARCHAR(500) NULL,
  type INT NOT NULL,
  type_state INT NOT NULL DEFAULT 0,
  state TINYINT NOT NULL DEFAULT 9,
  days INT NOT NULL DEFAULT 30,
  price BIGINT NOT NULL DEFAULT 0,
  price_type TINYINT NOT NULL DEFAULT 0,
  sort_order INT DEFAULT 0,
  created_at DATETIME NULL,
  updated_at DATETIME NULL,
  INDEX idx_store_type (type, state)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS user_inventory (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  uid BIGINT UNSIGNED NOT NULL,
  item_type VARCHAR(32) NOT NULL,
  item_id BIGINT UNSIGNED NOT NULL,
  quantity INT NOT NULL DEFAULT 1,
  active TINYINT NOT NULL DEFAULT 0,
  expires_at DATETIME NULL,
  state TINYINT NOT NULL DEFAULT 9,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NULL,
  INDEX idx_inventory_user (uid, item_type, item_id),
  INDEX idx_inventory_user_active (uid, item_type, state, active, expires_at),
  FOREIGN KEY (uid) REFERENCES users(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS medals (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(120) NOT NULL,
  icon VARCHAR(500) NULL,
  time INT DEFAULT 0,
  target BIGINT DEFAULT 0,
  target_type INT DEFAULT 0,
  target_id BIGINT DEFAULT 0,
  type INT DEFAULT 0,
  sort_order INT DEFAULT 0,
  sort INT DEFAULT 0,
  lvl INT DEFAULT 0,
  level_id BIGINT DEFAULT 0,
  state TINYINT DEFAULT 9,
  created_at DATETIME NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS user_medals (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  uid BIGINT UNSIGNED NOT NULL,
  medal_id BIGINT UNSIGNED NOT NULL,
  progress BIGINT NOT NULL DEFAULT 0,
  expires_at DATETIME NULL,
  is_used TINYINT NOT NULL DEFAULT 0,
  created_at DATETIME NOT NULL,
  UNIQUE KEY uq_user_medal (uid, medal_id),
  FOREIGN KEY (uid) REFERENCES users(id) ON DELETE CASCADE,
  FOREIGN KEY (medal_id) REFERENCES medals(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS agencies (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  uid BIGINT UNSIGNED NOT NULL,
  name VARCHAR(160) NOT NULL,
  icon VARCHAR(500) NULL,
  badge VARCHAR(500) NULL,
  notice VARCHAR(500) NULL,
  description TEXT NULL,
  percentage DECIMAL(6,2) NOT NULL DEFAULT 0,
  balance BIGINT NOT NULL DEFAULT 0,
  income BIGINT NOT NULL DEFAULT 0,
  level INT DEFAULT 0,
  state TINYINT NOT NULL DEFAULT 9,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NULL,
  FOREIGN KEY (uid) REFERENCES users(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS agency_members (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  agency_id BIGINT UNSIGNED NOT NULL,
  uid BIGINT UNSIGNED NOT NULL,
  role TINYINT NOT NULL DEFAULT 5,
  state TINYINT NOT NULL DEFAULT 9,
  joined_at DATETIME NOT NULL,
  UNIQUE KEY uq_agency_member (agency_id, uid),
  FOREIGN KEY (agency_id) REFERENCES agencies(id) ON DELETE CASCADE,
  FOREIGN KEY (uid) REFERENCES users(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS agency_requests (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  agency_id BIGINT UNSIGNED NOT NULL,
  uid BIGINT UNSIGNED NOT NULL,
  state TINYINT NOT NULL DEFAULT 1,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NULL,
  INDEX idx_agency_requests (agency_id, state),
  INDEX idx_agency_requests_uid (uid, state)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS rooms (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  uid BIGINT UNSIGNED NOT NULL,
  title VARCHAR(160) NOT NULL,
  type INT NOT NULL DEFAULT 0,
  state TINYINT NOT NULL DEFAULT 9,
  icon VARCHAR(500) NULL,
  bg VARCHAR(500) NULL,
  password VARCHAR(64) NULL,
  seat_count INT NOT NULL DEFAULT 9,
  is_live TINYINT NOT NULL DEFAULT 0,
  allow_messages TINYINT NOT NULL DEFAULT 1,
  allow_mic TINYINT NOT NULL DEFAULT 1,
  coin_number BIGINT NOT NULL DEFAULT 0,
  total_points BIGINT NOT NULL DEFAULT 0,
  carizma BIGINT NOT NULL DEFAULT 0,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NULL,
  FOREIGN KEY (uid) REFERENCES users(id) ON DELETE CASCADE,
  INDEX idx_rooms_live (is_live, state)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS room_members (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  rid BIGINT UNSIGNED NOT NULL,
  uid BIGINT UNSIGNED NOT NULL,
  role TINYINT NOT NULL DEFAULT 5,
  state TINYINT NOT NULL DEFAULT 9,
  online TINYINT NOT NULL DEFAULT 0,
  expires_at DATETIME NULL,
  joined_at DATETIME NULL,
  left_at DATETIME NULL,
  UNIQUE KEY uq_room_member (rid, uid),
  FOREIGN KEY (rid) REFERENCES rooms(id) ON DELETE CASCADE,
  FOREIGN KEY (uid) REFERENCES users(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS room_seats (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  rid BIGINT UNSIGNED NOT NULL,
  pos INT NOT NULL,
  uid BIGINT UNSIGNED NULL,
  state TINYINT NOT NULL DEFAULT 0,
  mic_state TINYINT NOT NULL DEFAULT 1,
  cam_state TINYINT NOT NULL DEFAULT 1,
  score BIGINT NOT NULL DEFAULT 0,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NULL,
  UNIQUE KEY uq_room_seat (rid, pos),
  INDEX idx_room_seats_user (rid, uid),
  FOREIGN KEY (rid) REFERENCES rooms(id) ON DELETE CASCADE,
  FOREIGN KEY (uid) REFERENCES users(id) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS room_seat_requests (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  rid BIGINT UNSIGNED NOT NULL,
  uid BIGINT UNSIGNED NOT NULL,
  pos INT NOT NULL,
  state TINYINT NOT NULL DEFAULT 1,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NULL,
  INDEX idx_seat_req (rid, state)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS gifts (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(120) NOT NULL,
  type INT NOT NULL DEFAULT 1,
  mark INT DEFAULT 0,
  coins BIGINT NOT NULL DEFAULT 0,
  icon VARCHAR(500) NULL,
  anim VARCHAR(500) NULL,
  is_all_notify TINYINT DEFAULT 0,
  is_cp TINYINT DEFAULT 0,
  global_notify_lvl INT DEFAULT 0,
  state TINYINT DEFAULT 9,
  sort_order INT DEFAULT 0,
  created_at DATETIME NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS gift_transactions (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  rid BIGINT UNSIGNED NOT NULL,
  uid BIGINT UNSIGNED NOT NULL,
  to_uid BIGINT UNSIGNED NOT NULL,
  gift_id BIGINT UNSIGNED NOT NULL,
  count INT NOT NULL DEFAULT 1,
  coins BIGINT NOT NULL DEFAULT 0,
  cashback BIGINT NOT NULL DEFAULT 0,
  created_at DATETIME NOT NULL,
  INDEX idx_gift_room (rid, created_at),
  INDEX idx_gift_uid (uid),
  INDEX idx_gift_to_uid (to_uid),
  INDEX idx_gift_created_uid (created_at, uid),
  INDEX idx_gift_created_to_uid (created_at, to_uid),
  INDEX idx_gift_created_room (created_at, rid)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS room_red_boxes (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  type TINYINT NOT NULL DEFAULT 1,
  rid BIGINT UNSIGNED NOT NULL,
  uid BIGINT UNSIGNED NOT NULL,
  coins BIGINT NOT NULL DEFAULT 0,
  reward BIGINT NOT NULL DEFAULT 0,
  coins_remaining BIGINT NOT NULL DEFAULT 0,
  people INT NOT NULL DEFAULT 1,
  people_claimed_count INT NOT NULL DEFAULT 0,
  seconds INT NOT NULL DEFAULT 60,
  expired_at DATETIME NULL,
  state TINYINT DEFAULT 9,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NULL,
  INDEX idx_red_box_room (rid, state)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS room_red_box_claims (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  box_id BIGINT UNSIGNED NOT NULL,
  uid BIGINT UNSIGNED NOT NULL,
  reward BIGINT NOT NULL DEFAULT 0,
  created_at DATETIME NOT NULL,
  UNIQUE KEY uq_red_box_claim (box_id, uid),
  INDEX idx_red_box_claim_uid (uid, created_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS conversations (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  user_one BIGINT UNSIGNED NOT NULL,
  user_two BIGINT UNSIGNED NOT NULL,
  last_message_id BIGINT UNSIGNED NULL,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NULL,
  UNIQUE KEY uq_conversation_pair (user_one, user_two)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS messages (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  chat_id BIGINT UNSIGNED NOT NULL,
  uid BIGINT UNSIGNED NOT NULL,
  content TEXT NULL,
  image_url VARCHAR(500) NULL,
  video_url VARCHAR(500) NULL,
  voice_url VARCHAR(500) NULL,
  is_forwarded TINYINT DEFAULT 0,
  is_view_once TINYINT DEFAULT 0,
  viewed_at DATETIME NULL,
  state TINYINT DEFAULT 1,
  target_state TINYINT DEFAULT 1,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NULL,
  INDEX idx_messages_chat (chat_id, id),
  INDEX idx_messages_unread (chat_id, uid, target_state, state)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS message_reactions (
  message_id BIGINT UNSIGNED NOT NULL,
  uid BIGINT UNSIGNED NOT NULL,
  emoji VARCHAR(32) NOT NULL,
  created_at DATETIME NOT NULL,
  PRIMARY KEY (message_id, uid)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS posts (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  uid BIGINT UNSIGNED NOT NULL,
  title VARCHAR(160) NULL,
  description TEXT NULL,
  url VARCHAR(500) NULL,
  like_count BIGINT NOT NULL DEFAULT 0,
  comment_count BIGINT NOT NULL DEFAULT 0,
  state TINYINT DEFAULT 9,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NULL,
  INDEX idx_posts_uid (uid, state),
  INDEX idx_posts_state_created (state, created_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS post_likes (
  post_id BIGINT UNSIGNED NOT NULL,
  uid BIGINT UNSIGNED NOT NULL,
  created_at DATETIME NOT NULL,
  PRIMARY KEY (post_id, uid)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS comments (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  post_id BIGINT UNSIGNED NOT NULL,
  uid BIGINT UNSIGNED NOT NULL,
  content TEXT NOT NULL,
  like_count BIGINT NOT NULL DEFAULT 0,
  state TINYINT DEFAULT 9,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NULL,
  INDEX idx_comments_post (post_id, state)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS comment_likes (
  comment_id BIGINT UNSIGNED NOT NULL,
  uid BIGINT UNSIGNED NOT NULL,
  created_at DATETIME NOT NULL,
  PRIMARY KEY (comment_id, uid)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS user_relations (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  uid BIGINT UNSIGNED NOT NULL,
  target_uid BIGINT UNSIGNED NOT NULL,
  type VARCHAR(32) NOT NULL,
  created_at DATETIME NOT NULL,
  UNIQUE KEY uq_relation (uid, target_uid, type)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS profile_visits (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  uid BIGINT UNSIGNED NOT NULL,
  visitor_uid BIGINT UNSIGNED NOT NULL,
  created_at DATETIME NOT NULL,
  INDEX idx_profile_visits (uid, id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS recharge_packages (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  product_id VARCHAR(120) NULL,
  android_product_id VARCHAR(120) NULL,
  ios_product_id VARCHAR(120) NULL,
  name VARCHAR(120) NOT NULL,
  coins BIGINT DEFAULT 0,
  diamonds BIGINT DEFAULT 0,
  usd_price DECIMAL(10,2) DEFAULT 0,
  state TINYINT DEFAULT 9,
  sort_order INT DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS recharge_requests (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  uid BIGINT UNSIGNED NOT NULL,
  agency_id BIGINT UNSIGNED DEFAULT 0,
  currency VARCHAR(20) NOT NULL DEFAULT 'coins',
  amount BIGINT NOT NULL DEFAULT 0,
  status TINYINT NOT NULL DEFAULT 1,
  note VARCHAR(500) NULL,
  processed_at DATETIME NULL,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NULL,
  INDEX idx_recharge_status (status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS wallet_transactions (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  uid BIGINT UNSIGNED NOT NULL,
  target_uid BIGINT UNSIGNED NULL,
  currency VARCHAR(20) NOT NULL,
  amount BIGINT NOT NULL,
  amount_decimal DECIMAL(18,8) NULL,
  type VARCHAR(40) NOT NULL,
  status TINYINT NOT NULL DEFAULT 9,
  meta JSON NULL,
  created_at DATETIME NOT NULL,
  INDEX idx_wallet_uid (uid, id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS cash_accounts (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  uid BIGINT UNSIGNED NOT NULL,
  type VARCHAR(40) NOT NULL,
  name VARCHAR(120) NULL,
  account VARCHAR(190) NOT NULL,
  created_at DATETIME NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS payment_logs (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  uid BIGINT UNSIGNED NOT NULL,
  provider VARCHAR(40) NOT NULL,
  product_id VARCHAR(120) NULL,
  token TEXT NULL,
  order_id VARCHAR(255) NULL,
  token_hash CHAR(64) NULL,
  amount BIGINT DEFAULT 0,
  currency VARCHAR(20) NULL,
  credited_coins BIGINT NOT NULL DEFAULT 0,
  credited_diamonds BIGINT NOT NULL DEFAULT 0,
  status TINYINT DEFAULT 1,
  raw_payload JSON NULL,
  error_text TEXT NULL,
  created_at DATETIME NOT NULL,
  verified_at DATETIME NULL,
  updated_at DATETIME NULL,
  INDEX idx_payment_uid (uid, id),
  INDEX idx_payment_token_hash (provider, token_hash),
  INDEX idx_payment_order_id (provider, order_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS banners (id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, title VARCHAR(120), image VARCHAR(500), url VARCHAR(500), state TINYINT DEFAULT 9, sort_order INT DEFAULT 0);
CREATE TABLE IF NOT EXISTS media_assets (id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, type VARCHAR(40), name VARCHAR(120), url VARCHAR(500), state TINYINT DEFAULT 9, sort_order INT DEFAULT 0);
CREATE TABLE IF NOT EXISTS emojis (id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, name VARCHAR(120), icon VARCHAR(500), state TINYINT DEFAULT 9, sort_order INT DEFAULT 0);
CREATE TABLE IF NOT EXISTS games (id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, name VARCHAR(120), icon VARCHAR(500), url VARCHAR(500), token VARCHAR(255), state TINYINT DEFAULT 9, sort_order INT DEFAULT 0);
CREATE TABLE IF NOT EXISTS rocket_levels (id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, lvl INT, name VARCHAR(120), score BIGINT, icon VARCHAR(500), `global` VARCHAR(500), anim VARCHAR(500), icon_anim VARCHAR(500), state TINYINT DEFAULT 9);
CREATE TABLE IF NOT EXISTS rocket_rewards (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  level_id BIGINT UNSIGNED NOT NULL,
  lvl INT NOT NULL DEFAULT 0,
  title VARCHAR(160) NULL,
  reward_type VARCHAR(40) NOT NULL DEFAULT 'coins',
  item_id BIGINT UNSIGNED NULL,
  quantity BIGINT NOT NULL DEFAULT 1,
  days INT NULL,
  state TINYINT NOT NULL DEFAULT 9,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NULL,
  INDEX idx_rocket_rewards_level (level_id, state),
  INDEX idx_rocket_rewards_lvl (lvl, state)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS rocket_records (id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, uid BIGINT UNSIGNED, rid BIGINT UNSIGNED, level_id BIGINT UNSIGNED, score BIGINT DEFAULT 0, created_at DATETIME, updated_at DATETIME);
CREATE TABLE IF NOT EXISTS notifications (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  type VARCHAR(50) NOT NULL DEFAULT 'system',
  uid BIGINT UNSIGNED NULL,
  sender_uid BIGINT UNSIGNED NULL,
  receiver_uid BIGINT UNSIGNED NULL,
  target_id BIGINT UNSIGNED NULL,
  target_type VARCHAR(50) NULL,
  title VARCHAR(160),
  body TEXT,
  image VARCHAR(500) NULL,
  data JSON NULL,
  state TINYINT DEFAULT 9,
  read_at DATETIME NULL,
  created_at DATETIME,
  updated_at DATETIME NULL,
  INDEX idx_notifications_receiver (receiver_uid, state, id),
  INDEX idx_notifications_type (type, created_at)
);
CREATE TABLE IF NOT EXISTS user_notification_settings (
  uid BIGINT UNSIGNED NOT NULL,
  type VARCHAR(50) NOT NULL,
  push_enabled TINYINT NOT NULL DEFAULT 1,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NULL,
  PRIMARY KEY (uid, type),
  INDEX idx_notification_settings_type (type, push_enabled)
);
CREATE TABLE IF NOT EXISTS reports (id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, uid BIGINT UNSIGNED, target_type VARCHAR(40), target_id BIGINT UNSIGNED, reason VARCHAR(255), status TINYINT DEFAULT 1, created_at DATETIME);

CREATE TABLE IF NOT EXISTS videos (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  uid BIGINT UNSIGNED NOT NULL,
  description TEXT NULL,
  url VARCHAR(500) NOT NULL,
  thum VARCHAR(500) NULL,
  thum_small VARCHAR(500) NULL,
  gif VARCHAR(500) NULL,
  multi_url JSON NULL,
  view_count BIGINT DEFAULT 0,
  sound_id BIGINT DEFAULT 0,
  privacy_type VARCHAR(30) DEFAULT 'everyone',
  allow_comments TINYINT DEFAULT 1,
  allow_duet TINYINT DEFAULT 1,
  allow_download TINYINT DEFAULT 1,
  allow_gift TINYINT DEFAULT 1,
  duration DECIMAL(10,3) DEFAULT 0,
  width INT DEFAULT 0,
  height INT DEFAULT 0,
  state TINYINT DEFAULT 1,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NULL,
  INDEX idx_videos_uid (uid, state)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS app_settings (
  setting_key VARCHAR(120) PRIMARY KEY,
  group_key VARCHAR(80) NOT NULL DEFAULT 'app',
  setting_value TEXT NULL,
  is_secret TINYINT NOT NULL DEFAULT 0,
  updated_at DATETIME NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT IGNORE INTO vip_packages (id, num, state, icon, price, renewal_price, days, color) VALUES (1, 1, 9, '', 1000, 800, 30, '255,215,0');
INSERT IGNORE INTO app_settings (setting_key, group_key, setting_value, is_secret, updated_at) VALUES
('agora_app_id', 'agora', 'CHANGE_ME_AGORA_APP_ID', 0, UTC_TIMESTAMP()),
('agora_app_certificate', 'agora', 'CHANGE_ME_AGORA_APP_CERTIFICATE', 1, UTC_TIMESTAMP()),
('bunny_storage_zone', 'bunny', 'CHANGE_ME_STORAGE_ZONE', 0, UTC_TIMESTAMP()),
('bunny_storage_api_key', 'bunny', 'CHANGE_ME_BUNNY_STORAGE_API_KEY', 1, UTC_TIMESTAMP()),
('image_storage_driver', 'uploads', 'server', 0, UTC_TIMESTAMP()),
('app_timezone', 'app', 'UTC', 0, UTC_TIMESTAMP()),
('google_play_package_name', 'payments', 'CHANGE_ME_ANDROID_PACKAGE', 0, UTC_TIMESTAMP()),
('google_play_service_account_json', 'payments', '', 1, UTC_TIMESTAMP()),
('agency_coins_per_100_usd', 'business', '1500000', 0, UTC_TIMESTAMP()),
('firebase_project_id', 'notifications', '', 0, UTC_TIMESTAMP()),
('firebase_service_account_json', 'notifications', '', 1, UTC_TIMESTAMP());


-- Admin dashboard, RBAC, and audit schema.
USE appchat_db;

CREATE TABLE IF NOT EXISTS admin_roles (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(120) NOT NULL,
  slug VARCHAR(120) NOT NULL UNIQUE,
  description VARCHAR(255) NULL,
  is_system TINYINT NOT NULL DEFAULT 0,
  state TINYINT NOT NULL DEFAULT 9,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS admin_permissions (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  module VARCHAR(80) NOT NULL,
  action VARCHAR(80) NOT NULL,
  slug VARCHAR(160) NOT NULL UNIQUE,
  name VARCHAR(160) NOT NULL,
  description VARCHAR(255) NULL,
  created_at DATETIME NOT NULL,
  INDEX idx_admin_permissions_module (module)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS admin_users (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(120) NOT NULL,
  email VARCHAR(190) NOT NULL UNIQUE,
  profile_image VARCHAR(500) NULL,
  password_hash VARCHAR(255) NOT NULL,
  state TINYINT NOT NULL DEFAULT 9,
  last_login_at DATETIME NULL,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NULL,
  INDEX idx_admin_users_state (state)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS admin_role_permissions (
  role_id BIGINT UNSIGNED NOT NULL,
  permission_id BIGINT UNSIGNED NOT NULL,
  PRIMARY KEY (role_id, permission_id),
  FOREIGN KEY (role_id) REFERENCES admin_roles(id) ON DELETE CASCADE,
  FOREIGN KEY (permission_id) REFERENCES admin_permissions(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS admin_user_roles (
  admin_id BIGINT UNSIGNED NOT NULL,
  role_id BIGINT UNSIGNED NOT NULL,
  PRIMARY KEY (admin_id, role_id),
  FOREIGN KEY (admin_id) REFERENCES admin_users(id) ON DELETE CASCADE,
  FOREIGN KEY (role_id) REFERENCES admin_roles(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS admin_sessions (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  admin_id BIGINT UNSIGNED NOT NULL,
  token_hash CHAR(64) NOT NULL UNIQUE,
  ip VARCHAR(64) NULL,
  user_agent VARCHAR(255) NULL,
  expires_at DATETIME NOT NULL,
  revoked_at DATETIME NULL,
  created_at DATETIME NOT NULL,
  last_seen_at DATETIME NULL,
  FOREIGN KEY (admin_id) REFERENCES admin_users(id) ON DELETE CASCADE,
  INDEX idx_admin_sessions_admin (admin_id),
  INDEX idx_admin_sessions_expiry (expires_at, revoked_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS admin_activity_logs (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  admin_id BIGINT UNSIGNED NULL,
  permission_slug VARCHAR(160) NULL,
  action VARCHAR(120) NOT NULL,
  target_type VARCHAR(80) NULL,
  target_id BIGINT UNSIGNED NULL,
  metadata JSON NULL,
  ip VARCHAR(64) NULL,
  created_at DATETIME NOT NULL,
  INDEX idx_admin_activity_admin (admin_id, id),
  INDEX idx_admin_activity_target (target_type, target_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT IGNORE INTO admin_roles (id, name, slug, description, is_system, state, created_at) VALUES
(1, 'Super Admin', 'super_admin', 'Full access to all dashboard modules.', 1, 9, UTC_TIMESTAMP()),
(2, 'Admin', 'admin', 'General administration except role ownership changes.', 1, 9, UTC_TIMESTAMP()),
(3, 'Store Manager', 'store_manager', 'Manage store items, gifts, VIP packages, and transactions.', 1, 9, UTC_TIMESTAMP()),
(4, 'Rooms Manager', 'rooms_manager', 'Manage rooms, room members, reports, and room media.', 1, 9, UTC_TIMESTAMP()),
(5, 'Users Manager', 'users_manager', 'Manage users, status, balances, and subscriptions.', 1, 9, UTC_TIMESTAMP()),
(6, 'Support', 'support', 'View users, reports, transactions, and room activity.', 1, 9, UTC_TIMESTAMP());

INSERT IGNORE INTO admin_permissions (module, action, slug, name, description, created_at) VALUES
('dashboard', 'view', 'dashboard.view', 'View dashboard', 'View counters and recent system activity.', UTC_TIMESTAMP()),
('users', 'view', 'users.view', 'View users', 'View and search users.', UTC_TIMESTAMP()),
('users', 'edit', 'users.edit', 'Edit users', 'Edit user profile fields.', UTC_TIMESTAMP()),
('users', 'ban', 'users.ban', 'Ban users', 'Ban, unban, or disable users.', UTC_TIMESTAMP()),
('users', 'balance', 'users.balance', 'Manage balances', 'Adjust user coins and diamonds.', UTC_TIMESTAMP()),
('users', 'vip', 'users.vip', 'Manage user VIP', 'Grant or cancel VIP for users.', UTC_TIMESTAMP()),
('users', 'activity', 'users.activity', 'View user activity', 'View user activity and logs.', UTC_TIMESTAMP()),
('agencies', 'view', 'agencies.view', 'View agencies', 'View and search agencies.', UTC_TIMESTAMP()),
('agencies', 'edit', 'agencies.edit', 'Edit agencies', 'Create and edit agency profile data.', UTC_TIMESTAMP()),
('agencies', 'delete', 'agencies.delete', 'Delete agencies', 'Soft delete agencies when safe.', UTC_TIMESTAMP()),
('agencies', 'members.view', 'agencies.members.view', 'View agency members', 'View and search agency members.', UTC_TIMESTAMP()),
('agencies', 'members.add', 'agencies.members.add', 'Add agency members', 'Add users to agencies.', UTC_TIMESTAMP()),
('agencies', 'members.edit', 'agencies.members.edit', 'Edit agency members', 'Change agency member role and state.', UTC_TIMESTAMP()),
('agencies', 'members.remove', 'agencies.members.remove', 'Remove agency members', 'Remove users from agencies.', UTC_TIMESTAMP()),
('agencies', 'owner', 'agencies.owner', 'Change agency owner', 'Change the owner of an agency.', UTC_TIMESTAMP()),
('posts', 'view', 'posts.view', 'View posts', 'View and search user posts and post comments.', UTC_TIMESTAMP()),
('posts', 'manage', 'posts.manage', 'Manage posts', 'Disable user posts and post comments.', UTC_TIMESTAMP()),
('rooms', 'view', 'rooms.view', 'View rooms', 'View and search voice rooms.', UTC_TIMESTAMP()),
('rooms', 'edit', 'rooms.edit', 'Edit rooms', 'Edit room settings and details.', UTC_TIMESTAMP()),
('rooms', 'disable', 'rooms.disable', 'Disable rooms', 'Disable or delete rooms.', UTC_TIMESTAMP()),
('rooms', 'members', 'rooms.members', 'Manage room members', 'Manage room member roles and room moderation.', UTC_TIMESTAMP()),
('vip', 'view', 'vip.view', 'View VIP', 'View VIP plans and subscriptions.', UTC_TIMESTAMP()),
('vip', 'manage', 'vip.manage', 'Manage VIP', 'Create, edit, and delete VIP plans and privileges.', UTC_TIMESTAMP()),
('store', 'view', 'store.view', 'View store', 'View store items and gifts.', UTC_TIMESTAMP()),
('store', 'manage', 'store.manage', 'Manage store', 'Create, edit, delete, and reorder store items and gifts.', UTC_TIMESTAMP()),
('transactions', 'view', 'transactions.view', 'View transactions', 'View payments, withdrawal requests, wallet logs, and gifts.', UTC_TIMESTAMP()),
('transactions', 'manage', 'transactions.manage', 'Manage transactions', 'Approve or reject withdrawal requests.', UTC_TIMESTAMP()),
('reports', 'view', 'reports.view', 'View reports', 'View user, room, and content reports.', UTC_TIMESTAMP()),
('reports', 'manage', 'reports.manage', 'Manage reports', 'Resolve reports and take moderation actions.', UTC_TIMESTAMP()),
('settings', 'view', 'settings.view', 'View settings', 'View app and business settings.', UTC_TIMESTAMP()),
('settings', 'manage', 'settings.manage', 'Manage settings', 'Create and edit app settings.', UTC_TIMESTAMP()),
('content', 'view', 'content.view', 'View content tools', 'View banners, media, games, emojis, levels, and medals.', UTC_TIMESTAMP()),
('content', 'manage', 'content.manage', 'Manage content tools', 'Manage banners, media, games, emojis, levels, and medals.', UTC_TIMESTAMP()),
('roles', 'view', 'roles.view', 'View roles', 'View roles, permissions, and admin users.', UTC_TIMESTAMP()),
('roles', 'manage', 'roles.manage', 'Manage roles', 'Manage roles, permissions, and admin user assignments.', UTC_TIMESTAMP()),
('audit', 'view', 'audit.view', 'View audit logs', 'View admin activity logs.', UTC_TIMESTAMP());

INSERT IGNORE INTO admin_users (id, name, email, password_hash, state, created_at)
VALUES (1, 'Super Admin', 'admin@appchat.com', '$2y$10$YPdKwnEJPkQzLO2oDlQg7uJhR5qMqEoHbY3150SmhYnX4WIO8fYci', 9, UTC_TIMESTAMP());

INSERT IGNORE INTO admin_user_roles (admin_id, role_id) VALUES (1, 1);

INSERT IGNORE INTO admin_role_permissions (role_id, permission_id)
SELECT 1, id FROM admin_permissions;

INSERT IGNORE INTO admin_role_permissions (role_id, permission_id)
SELECT 2, id FROM admin_permissions
WHERE slug NOT IN ('roles.manage');

INSERT IGNORE INTO admin_role_permissions (role_id, permission_id)
SELECT 3, id FROM admin_permissions
WHERE slug IN ('dashboard.view', 'store.view', 'store.manage', 'vip.view', 'vip.manage', 'transactions.view', 'transactions.manage', 'settings.view', 'content.view', 'content.manage', 'audit.view');

INSERT IGNORE INTO admin_role_permissions (role_id, permission_id)
SELECT 4, id FROM admin_permissions
WHERE slug IN ('dashboard.view', 'rooms.view', 'rooms.edit', 'rooms.disable', 'rooms.members', 'reports.view', 'reports.manage', 'users.view', 'users.activity', 'content.view', 'audit.view');

INSERT IGNORE INTO admin_role_permissions (role_id, permission_id)
SELECT 5, id FROM admin_permissions
WHERE slug IN ('dashboard.view', 'users.view', 'users.edit', 'users.ban', 'users.balance', 'users.vip', 'users.activity', 'vip.view', 'transactions.view', 'audit.view');

INSERT IGNORE INTO admin_role_permissions (role_id, permission_id)
SELECT 6, id FROM admin_permissions
WHERE slug IN ('dashboard.view', 'users.view', 'users.activity', 'rooms.view', 'reports.view', 'transactions.view');


-- Curated included digital assets: 10 emojis, 5 user frames, 5 room entry animations, 3 VIP levels, 3 Rocket levels.
INSERT INTO `emojis` (`id`, `name`, `icon`, `state`, `sort_order`) VALUES (16, 'T', 'https://your-domain.com/uploads/appchat_seed_assets/emojis/server/16_server_emoji.webp', 9, 1) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `emojis` (`id`, `name`, `icon`, `state`, `sort_order`) VALUES (17, 'Emoji', 'https://your-domain.com/uploads/appchat_seed_assets/emojis/server/17_server_emoji.webp', 9, 2) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `emojis` (`id`, `name`, `icon`, `state`, `sort_order`) VALUES (18, 'Emoji', 'https://your-domain.com/uploads/appchat_seed_assets/emojis/server/18_server_emoji.webp', 9, 3) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `emojis` (`id`, `name`, `icon`, `state`, `sort_order`) VALUES (19, 'Emoji', 'https://your-domain.com/uploads/appchat_seed_assets/emojis/server/19_server_emoji.webp', 9, 4) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `emojis` (`id`, `name`, `icon`, `state`, `sort_order`) VALUES (20, 'Emoji', 'https://your-domain.com/uploads/appchat_seed_assets/emojis/server/20_server_emoji.webp', 9, 5) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `emojis` (`id`, `name`, `icon`, `state`, `sort_order`) VALUES (21, 'Emoji', 'https://your-domain.com/uploads/appchat_seed_assets/emojis/server/21_server_emoji.webp', 9, 6) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `emojis` (`id`, `name`, `icon`, `state`, `sort_order`) VALUES (22, 'Emoji', 'https://your-domain.com/uploads/appchat_seed_assets/emojis/server/22_server_emoji.webp', 9, 7) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `emojis` (`id`, `name`, `icon`, `state`, `sort_order`) VALUES (23, 'Emoji', 'https://your-domain.com/uploads/appchat_seed_assets/emojis/server/23_server_emoji.webp', 9, 8) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `emojis` (`id`, `name`, `icon`, `state`, `sort_order`) VALUES (24, 'Emoji', 'https://your-domain.com/uploads/appchat_seed_assets/emojis/server/24_server_emoji.webp', 9, 9) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `emojis` (`id`, `name`, `icon`, `state`, `sort_order`) VALUES (25, 'Emoji', 'https://your-domain.com/uploads/appchat_seed_assets/emojis/server/25_server_emoji.webp', 9, 10) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `gifts` (`id`, `name`, `type`, `mark`, `coins`, `icon`, `anim`, `is_all_notify`, `is_cp`, `global_notify_lvl`, `state`, `sort_order`, `created_at`) VALUES (3, 'Small Fairy', 1, 0, 3160, 'https://your-domain.com/uploads/appchat_seed_assets/gifts/gift/3_icon.png', 'https://your-domain.com/uploads/appchat_seed_assets/gifts/gift/3_anim.svga', 0, 0, 0, 9, 1, UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `type` = VALUES(`type`), `mark` = VALUES(`mark`), `coins` = VALUES(`coins`), `icon` = VALUES(`icon`), `anim` = VALUES(`anim`), `is_all_notify` = VALUES(`is_all_notify`), `is_cp` = VALUES(`is_cp`), `global_notify_lvl` = VALUES(`global_notify_lvl`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `gifts` (`id`, `name`, `type`, `mark`, `coins`, `icon`, `anim`, `is_all_notify`, `is_cp`, `global_notify_lvl`, `state`, `sort_order`, `created_at`) VALUES (9, 'Rose', 1, 0, 320, 'https://your-domain.com/uploads/appchat_seed_assets/gifts/gift/9_icon.png', NULL, 0, 0, 0, 9, 2, UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `type` = VALUES(`type`), `mark` = VALUES(`mark`), `coins` = VALUES(`coins`), `icon` = VALUES(`icon`), `anim` = VALUES(`anim`), `is_all_notify` = VALUES(`is_all_notify`), `is_cp` = VALUES(`is_cp`), `global_notify_lvl` = VALUES(`global_notify_lvl`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `gifts` (`id`, `name`, `type`, `mark`, `coins`, `icon`, `anim`, `is_all_notify`, `is_cp`, `global_notify_lvl`, `state`, `sort_order`, `created_at`) VALUES (11, 'Star Rocket', 1, 0, 1630, 'https://your-domain.com/uploads/appchat_seed_assets/gifts/gift/11_icon.png', NULL, 0, 0, 0, 9, 3, UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `type` = VALUES(`type`), `mark` = VALUES(`mark`), `coins` = VALUES(`coins`), `icon` = VALUES(`icon`), `anim` = VALUES(`anim`), `is_all_notify` = VALUES(`is_all_notify`), `is_cp` = VALUES(`is_cp`), `global_notify_lvl` = VALUES(`global_notify_lvl`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `gifts` (`id`, `name`, `type`, `mark`, `coins`, `icon`, `anim`, `is_all_notify`, `is_cp`, `global_notify_lvl`, `state`, `sort_order`, `created_at`) VALUES (19, 'Eid Camel', 1, 0, 1110, 'https://your-domain.com/uploads/appchat_seed_assets/gifts/gift/19_icon.png', 'https://your-domain.com/uploads/appchat_seed_assets/gifts/gift/19_anim.svga', 0, 0, 0, 9, 4, UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `type` = VALUES(`type`), `mark` = VALUES(`mark`), `coins` = VALUES(`coins`), `icon` = VALUES(`icon`), `anim` = VALUES(`anim`), `is_all_notify` = VALUES(`is_all_notify`), `is_cp` = VALUES(`is_cp`), `global_notify_lvl` = VALUES(`global_notify_lvl`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `gifts` (`id`, `name`, `type`, `mark`, `coins`, `icon`, `anim`, `is_all_notify`, `is_cp`, `global_notify_lvl`, `state`, `sort_order`, `created_at`) VALUES (20, 'Pinwheel', 1, 0, 1220, 'https://your-domain.com/uploads/appchat_seed_assets/gifts/gift/20_icon.png', 'https://your-domain.com/uploads/appchat_seed_assets/gifts/gift/20_anim.svga', 0, 0, 0, 9, 5, UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `type` = VALUES(`type`), `mark` = VALUES(`mark`), `coins` = VALUES(`coins`), `icon` = VALUES(`icon`), `anim` = VALUES(`anim`), `is_all_notify` = VALUES(`is_all_notify`), `is_cp` = VALUES(`is_cp`), `global_notify_lvl` = VALUES(`global_notify_lvl`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `gifts` (`id`, `name`, `type`, `mark`, `coins`, `icon`, `anim`, `is_all_notify`, `is_cp`, `global_notify_lvl`, `state`, `sort_order`, `created_at`) VALUES (25, 'Wishing', 1, 0, 2760, 'https://your-domain.com/uploads/appchat_seed_assets/gifts/gift/25_icon.png', 'https://your-domain.com/uploads/appchat_seed_assets/gifts/gift/25_anim.svga', 0, 0, 0, 9, 6, UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `type` = VALUES(`type`), `mark` = VALUES(`mark`), `coins` = VALUES(`coins`), `icon` = VALUES(`icon`), `anim` = VALUES(`anim`), `is_all_notify` = VALUES(`is_all_notify`), `is_cp` = VALUES(`is_cp`), `global_notify_lvl` = VALUES(`global_notify_lvl`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `gifts` (`id`, `name`, `type`, `mark`, `coins`, `icon`, `anim`, `is_all_notify`, `is_cp`, `global_notify_lvl`, `state`, `sort_order`, `created_at`) VALUES (31, 'Baby', 1, 0, 1630, 'https://your-domain.com/uploads/appchat_seed_assets/gifts/gift/31_icon.png', 'https://your-domain.com/uploads/appchat_seed_assets/gifts/gift/31_anim.svga', 0, 0, 0, 9, 7, UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `type` = VALUES(`type`), `mark` = VALUES(`mark`), `coins` = VALUES(`coins`), `icon` = VALUES(`icon`), `anim` = VALUES(`anim`), `is_all_notify` = VALUES(`is_all_notify`), `is_cp` = VALUES(`is_cp`), `global_notify_lvl` = VALUES(`global_notify_lvl`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `gifts` (`id`, `name`, `type`, `mark`, `coins`, `icon`, `anim`, `is_all_notify`, `is_cp`, `global_notify_lvl`, `state`, `sort_order`, `created_at`) VALUES (47, 'Romance', 1, 0, 2540, 'https://your-domain.com/uploads/appchat_seed_assets/gifts/gift/47_icon.png', 'https://your-domain.com/uploads/appchat_seed_assets/gifts/gift/47_anim.svga', 0, 0, 0, 9, 8, UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `type` = VALUES(`type`), `mark` = VALUES(`mark`), `coins` = VALUES(`coins`), `icon` = VALUES(`icon`), `anim` = VALUES(`anim`), `is_all_notify` = VALUES(`is_all_notify`), `is_cp` = VALUES(`is_cp`), `global_notify_lvl` = VALUES(`global_notify_lvl`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `gifts` (`id`, `name`, `type`, `mark`, `coins`, `icon`, `anim`, `is_all_notify`, `is_cp`, `global_notify_lvl`, `state`, `sort_order`, `created_at`) VALUES (52, 'I''M Moved By You', 1, 0, 5580, 'https://your-domain.com/uploads/appchat_seed_assets/gifts/gift/52_icon.png', 'https://your-domain.com/uploads/appchat_seed_assets/gifts/gift/52_anim.svga', 0, 0, 0, 9, 9, UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `type` = VALUES(`type`), `mark` = VALUES(`mark`), `coins` = VALUES(`coins`), `icon` = VALUES(`icon`), `anim` = VALUES(`anim`), `is_all_notify` = VALUES(`is_all_notify`), `is_cp` = VALUES(`is_cp`), `global_notify_lvl` = VALUES(`global_notify_lvl`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `gifts` (`id`, `name`, `type`, `mark`, `coins`, `icon`, `anim`, `is_all_notify`, `is_cp`, `global_notify_lvl`, `state`, `sort_order`, `created_at`) VALUES (54, 'A Beauty', 1, 0, 3710, 'https://your-domain.com/uploads/appchat_seed_assets/gifts/gift/54_icon.png', 'https://your-domain.com/uploads/appchat_seed_assets/gifts/gift/54_anim.svga', 0, 0, 0, 9, 10, UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `type` = VALUES(`type`), `mark` = VALUES(`mark`), `coins` = VALUES(`coins`), `icon` = VALUES(`icon`), `anim` = VALUES(`anim`), `is_all_notify` = VALUES(`is_all_notify`), `is_cp` = VALUES(`is_cp`), `global_notify_lvl` = VALUES(`global_notify_lvl`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `store_items` (`id`, `name`, `img`, `animation`, `type`, `type_state`, `state`, `days`, `price`, `price_type`, `sort_order`, `created_at`, `updated_at`) VALUES (5, 'Rolls Royce', 'https://your-domain.com/uploads/appchat_seed_assets/store_items/entry/5_image.png', 'https://your-domain.com/uploads/appchat_seed_assets/store_items/entry/5_animation.svga', 2, 0, 9, 30, 5500, 0, 1, UTC_TIMESTAMP(), UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `img` = VALUES(`img`), `animation` = VALUES(`animation`), `type` = VALUES(`type`), `type_state` = VALUES(`type_state`), `state` = VALUES(`state`), `days` = VALUES(`days`), `price` = VALUES(`price`), `price_type` = VALUES(`price_type`), `sort_order` = VALUES(`sort_order`), `updated_at` = VALUES(`updated_at`);
INSERT INTO `store_items` (`id`, `name`, `img`, `animation`, `type`, `type_state`, `state`, `days`, `price`, `price_type`, `sort_order`, `created_at`, `updated_at`) VALUES (6, 'Ferrari', 'https://your-domain.com/uploads/appchat_seed_assets/store_items/entry/6_image.png', 'https://your-domain.com/uploads/appchat_seed_assets/store_items/entry/6_animation.svga', 2, 0, 9, 30, 8800, 0, 2, UTC_TIMESTAMP(), UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `img` = VALUES(`img`), `animation` = VALUES(`animation`), `type` = VALUES(`type`), `type_state` = VALUES(`type_state`), `state` = VALUES(`state`), `days` = VALUES(`days`), `price` = VALUES(`price`), `price_type` = VALUES(`price_type`), `sort_order` = VALUES(`sort_order`), `updated_at` = VALUES(`updated_at`);
INSERT INTO `store_items` (`id`, `name`, `img`, `animation`, `type`, `type_state`, `state`, `days`, `price`, `price_type`, `sort_order`, `created_at`, `updated_at`) VALUES (7, 'Ghost', 'https://your-domain.com/uploads/appchat_seed_assets/store_items/entry/7_image.png', 'https://your-domain.com/uploads/appchat_seed_assets/store_items/entry/7_animation.svga', 2, 0, 9, 30, 12400, 0, 3, UTC_TIMESTAMP(), UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `img` = VALUES(`img`), `animation` = VALUES(`animation`), `type` = VALUES(`type`), `type_state` = VALUES(`type_state`), `state` = VALUES(`state`), `days` = VALUES(`days`), `price` = VALUES(`price`), `price_type` = VALUES(`price_type`), `sort_order` = VALUES(`sort_order`), `updated_at` = VALUES(`updated_at`);
INSERT INTO `store_items` (`id`, `name`, `img`, `animation`, `type`, `type_state`, `state`, `days`, `price`, `price_type`, `sort_order`, `created_at`, `updated_at`) VALUES (8, 'Queen', 'https://your-domain.com/uploads/appchat_seed_assets/store_items/entry/8_image.png', 'https://your-domain.com/uploads/appchat_seed_assets/store_items/entry/8_animation.svga', 2, 0, 9, 30, 21700, 0, 4, UTC_TIMESTAMP(), UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `img` = VALUES(`img`), `animation` = VALUES(`animation`), `type` = VALUES(`type`), `type_state` = VALUES(`type_state`), `state` = VALUES(`state`), `days` = VALUES(`days`), `price` = VALUES(`price`), `price_type` = VALUES(`price_type`), `sort_order` = VALUES(`sort_order`), `updated_at` = VALUES(`updated_at`);
INSERT INTO `store_items` (`id`, `name`, `img`, `animation`, `type`, `type_state`, `state`, `days`, `price`, `price_type`, `sort_order`, `created_at`, `updated_at`) VALUES (78, 'Item 78', 'https://your-domain.com/uploads/appchat_seed_assets/store_items/entry/78_image.png', 'https://your-domain.com/uploads/appchat_seed_assets/store_items/entry/78_animation.svga', 2, 0, 9, 30, 17000, 0, 5, UTC_TIMESTAMP(), UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `img` = VALUES(`img`), `animation` = VALUES(`animation`), `type` = VALUES(`type`), `type_state` = VALUES(`type_state`), `state` = VALUES(`state`), `days` = VALUES(`days`), `price` = VALUES(`price`), `price_type` = VALUES(`price_type`), `sort_order` = VALUES(`sort_order`), `updated_at` = VALUES(`updated_at`);
INSERT INTO `store_items` (`id`, `name`, `img`, `animation`, `type`, `type_state`, `state`, `days`, `price`, `price_type`, `sort_order`, `created_at`, `updated_at`) VALUES (1, 'Aa', 'https://your-domain.com/uploads/appchat_seed_assets/store_items/frame/1_image.webp', NULL, 0, 0, 9, 30, 1000, 0, 1, UTC_TIMESTAMP(), UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `img` = VALUES(`img`), `animation` = VALUES(`animation`), `type` = VALUES(`type`), `type_state` = VALUES(`type_state`), `state` = VALUES(`state`), `days` = VALUES(`days`), `price` = VALUES(`price`), `price_type` = VALUES(`price_type`), `sort_order` = VALUES(`sort_order`), `updated_at` = VALUES(`updated_at`);
INSERT INTO `store_items` (`id`, `name`, `img`, `animation`, `type`, `type_state`, `state`, `days`, `price`, `price_type`, `sort_order`, `created_at`, `updated_at`) VALUES (2, 'Qq', 'https://your-domain.com/uploads/appchat_seed_assets/store_items/frame/2_image.webp', NULL, 0, 0, 9, 30, 2000, 0, 2, UTC_TIMESTAMP(), UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `img` = VALUES(`img`), `animation` = VALUES(`animation`), `type` = VALUES(`type`), `type_state` = VALUES(`type_state`), `state` = VALUES(`state`), `days` = VALUES(`days`), `price` = VALUES(`price`), `price_type` = VALUES(`price_type`), `sort_order` = VALUES(`sort_order`), `updated_at` = VALUES(`updated_at`);
INSERT INTO `store_items` (`id`, `name`, `img`, `animation`, `type`, `type_state`, `state`, `days`, `price`, `price_type`, `sort_order`, `created_at`, `updated_at`) VALUES (3, 'W', 'https://your-domain.com/uploads/appchat_seed_assets/store_items/frame/3_image.webp', NULL, 0, 0, 9, 30, 3000, 0, 3, UTC_TIMESTAMP(), UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `img` = VALUES(`img`), `animation` = VALUES(`animation`), `type` = VALUES(`type`), `type_state` = VALUES(`type_state`), `state` = VALUES(`state`), `days` = VALUES(`days`), `price` = VALUES(`price`), `price_type` = VALUES(`price_type`), `sort_order` = VALUES(`sort_order`), `updated_at` = VALUES(`updated_at`);
INSERT INTO `store_items` (`id`, `name`, `img`, `animation`, `type`, `type_state`, `state`, `days`, `price`, `price_type`, `sort_order`, `created_at`, `updated_at`) VALUES (4, 'Sweet', 'https://your-domain.com/uploads/appchat_seed_assets/store_items/frame/4_image.webp', NULL, 0, 0, 9, 30, 4000, 0, 4, UTC_TIMESTAMP(), UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `img` = VALUES(`img`), `animation` = VALUES(`animation`), `type` = VALUES(`type`), `type_state` = VALUES(`type_state`), `state` = VALUES(`state`), `days` = VALUES(`days`), `price` = VALUES(`price`), `price_type` = VALUES(`price_type`), `sort_order` = VALUES(`sort_order`), `updated_at` = VALUES(`updated_at`);
INSERT INTO `store_items` (`id`, `name`, `img`, `animation`, `type`, `type_state`, `state`, `days`, `price`, `price_type`, `sort_order`, `created_at`, `updated_at`) VALUES (72, 'Item 72', 'https://your-domain.com/uploads/appchat_seed_assets/store_items/frame/72_image.webp', 'https://your-domain.com/uploads/appchat_seed_assets/store_items/frame/72_animation.svga', 0, 0, 9, 30, 11000, 0, 5, UTC_TIMESTAMP(), UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), `img` = VALUES(`img`), `animation` = VALUES(`animation`), `type` = VALUES(`type`), `type_state` = VALUES(`type_state`), `state` = VALUES(`state`), `days` = VALUES(`days`), `price` = VALUES(`price`), `price_type` = VALUES(`price_type`), `sort_order` = VALUES(`sort_order`), `updated_at` = VALUES(`updated_at`);
INSERT INTO `vip_packages` (`id`, `num`, `state`, `icon`, `profile_frame`, `bg`, `entry_effect`, `name_entry_effect`, `frame`, `bubble`, `price`, `renewal_price`, `days`, `color`, `sort_order`, `created_at`, `updated_at`) VALUES (1, 1, 9, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_1/vip_1_icon.webp', 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_1/vip_1_profile_frame.png', 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_1/vip_1_bg.png', 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_1/vip_1_entry_effect.svga', 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_1/vip_1_name_entry_effect.webp', 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_1/vip_1_frame.webp', 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_1/vip_1_bubble.png', 10000, 8500, 30, '99,230,210', 1, UTC_TIMESTAMP(), UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `num` = VALUES(`num`), `state` = VALUES(`state`), `icon` = VALUES(`icon`), `profile_frame` = VALUES(`profile_frame`), `bg` = VALUES(`bg`), `entry_effect` = VALUES(`entry_effect`), `name_entry_effect` = VALUES(`name_entry_effect`), `frame` = VALUES(`frame`), `bubble` = VALUES(`bubble`), `price` = VALUES(`price`), `renewal_price` = VALUES(`renewal_price`), `days` = VALUES(`days`), `color` = VALUES(`color`), `sort_order` = VALUES(`sort_order`), `updated_at` = VALUES(`updated_at`);
INSERT INTO `vip_packages` (`id`, `num`, `state`, `icon`, `profile_frame`, `bg`, `entry_effect`, `name_entry_effect`, `frame`, `bubble`, `price`, `renewal_price`, `days`, `color`, `sort_order`, `created_at`, `updated_at`) VALUES (2, 2, 9, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_2/vip_2_icon.webp', 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_2/vip_2_profile_frame.png', 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_2/vip_2_bg.png', 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_2/vip_2_entry_effect.svga', 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_2/vip_2_name_entry_effect.webp', 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_2/vip_2_frame.webp', 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_2/vip_2_bubble.png', 30000, 25500, 30, '231,184,90', 2, UTC_TIMESTAMP(), UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `num` = VALUES(`num`), `state` = VALUES(`state`), `icon` = VALUES(`icon`), `profile_frame` = VALUES(`profile_frame`), `bg` = VALUES(`bg`), `entry_effect` = VALUES(`entry_effect`), `name_entry_effect` = VALUES(`name_entry_effect`), `frame` = VALUES(`frame`), `bubble` = VALUES(`bubble`), `price` = VALUES(`price`), `renewal_price` = VALUES(`renewal_price`), `days` = VALUES(`days`), `color` = VALUES(`color`), `sort_order` = VALUES(`sort_order`), `updated_at` = VALUES(`updated_at`);
INSERT INTO `vip_packages` (`id`, `num`, `state`, `icon`, `profile_frame`, `bg`, `entry_effect`, `name_entry_effect`, `frame`, `bubble`, `price`, `renewal_price`, `days`, `color`, `sort_order`, `created_at`, `updated_at`) VALUES (3, 3, 9, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_3/vip_3_icon.webp', 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_3/vip_3_profile_frame.png', 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_3/vip_3_bg.png', 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_3/vip_3_entry_effect.svga', 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_3/vip_3_name_entry_effect.webp', 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_3/vip_3_frame.webp', 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_3/vip_3_bubble.png', 70000, 59500, 30, '85,214,245', 3, UTC_TIMESTAMP(), UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `num` = VALUES(`num`), `state` = VALUES(`state`), `icon` = VALUES(`icon`), `profile_frame` = VALUES(`profile_frame`), `bg` = VALUES(`bg`), `entry_effect` = VALUES(`entry_effect`), `name_entry_effect` = VALUES(`name_entry_effect`), `frame` = VALUES(`frame`), `bubble` = VALUES(`bubble`), `price` = VALUES(`price`), `renewal_price` = VALUES(`renewal_price`), `days` = VALUES(`days`), `color` = VALUES(`color`), `sort_order` = VALUES(`sort_order`), `updated_at` = VALUES(`updated_at`);
INSERT INTO `vip_privileges` (`id`, `vip_id`, `shop_item`, `icon`, `state`, `type`, `name`, `sort_order`) VALUES (101, 1, NULL, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_1/privileges/vip_1_privilege_1.png', 9, 1, 'Broadcast', 1) ON DUPLICATE KEY UPDATE `vip_id` = VALUES(`vip_id`), `shop_item` = VALUES(`shop_item`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `type` = VALUES(`type`), `name` = VALUES(`name`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `vip_privileges` (`id`, `vip_id`, `shop_item`, `icon`, `state`, `type`, `name`, `sort_order`) VALUES (102, 1, NULL, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_1/privileges/vip_1_privilege_2.png', 9, 2, 'Business Card', 2) ON DUPLICATE KEY UPDATE `vip_id` = VALUES(`vip_id`), `shop_item` = VALUES(`shop_item`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `type` = VALUES(`type`), `name` = VALUES(`name`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `vip_privileges` (`id`, `vip_id`, `shop_item`, `icon`, `state`, `type`, `name`, `sort_order`) VALUES (103, 1, NULL, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_1/privileges/vip_1_privilege_3.png', 9, 3, 'Entry', 3) ON DUPLICATE KEY UPDATE `vip_id` = VALUES(`vip_id`), `shop_item` = VALUES(`shop_item`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `type` = VALUES(`type`), `name` = VALUES(`name`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `vip_privileges` (`id`, `vip_id`, `shop_item`, `icon`, `state`, `type`, `name`, `sort_order`) VALUES (104, 1, NULL, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_1/privileges/vip_1_privilege_4.png', 9, 4, 'Emoji', 4) ON DUPLICATE KEY UPDATE `vip_id` = VALUES(`vip_id`), `shop_item` = VALUES(`shop_item`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `type` = VALUES(`type`), `name` = VALUES(`name`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `vip_privileges` (`id`, `vip_id`, `shop_item`, `icon`, `state`, `type`, `name`, `sort_order`) VALUES (105, 1, NULL, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_1/privileges/vip_1_privilege_5.png', 9, 5, 'Entry Effect', 5) ON DUPLICATE KEY UPDATE `vip_id` = VALUES(`vip_id`), `shop_item` = VALUES(`shop_item`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `type` = VALUES(`type`), `name` = VALUES(`name`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `vip_privileges` (`id`, `vip_id`, `shop_item`, `icon`, `state`, `type`, `name`, `sort_order`) VALUES (201, 2, NULL, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_2/privileges/vip_2_privilege_1.png', 9, 1, 'Broadcast', 1) ON DUPLICATE KEY UPDATE `vip_id` = VALUES(`vip_id`), `shop_item` = VALUES(`shop_item`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `type` = VALUES(`type`), `name` = VALUES(`name`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `vip_privileges` (`id`, `vip_id`, `shop_item`, `icon`, `state`, `type`, `name`, `sort_order`) VALUES (202, 2, NULL, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_2/privileges/vip_2_privilege_2.png', 9, 2, 'Business Card', 2) ON DUPLICATE KEY UPDATE `vip_id` = VALUES(`vip_id`), `shop_item` = VALUES(`shop_item`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `type` = VALUES(`type`), `name` = VALUES(`name`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `vip_privileges` (`id`, `vip_id`, `shop_item`, `icon`, `state`, `type`, `name`, `sort_order`) VALUES (203, 2, NULL, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_2/privileges/vip_2_privilege_3.png', 9, 3, 'Entry', 3) ON DUPLICATE KEY UPDATE `vip_id` = VALUES(`vip_id`), `shop_item` = VALUES(`shop_item`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `type` = VALUES(`type`), `name` = VALUES(`name`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `vip_privileges` (`id`, `vip_id`, `shop_item`, `icon`, `state`, `type`, `name`, `sort_order`) VALUES (204, 2, NULL, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_2/privileges/vip_2_privilege_4.png', 9, 4, 'Emoji', 4) ON DUPLICATE KEY UPDATE `vip_id` = VALUES(`vip_id`), `shop_item` = VALUES(`shop_item`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `type` = VALUES(`type`), `name` = VALUES(`name`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `vip_privileges` (`id`, `vip_id`, `shop_item`, `icon`, `state`, `type`, `name`, `sort_order`) VALUES (205, 2, NULL, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_2/privileges/vip_2_privilege_5.png', 9, 5, 'Entry Effect', 5) ON DUPLICATE KEY UPDATE `vip_id` = VALUES(`vip_id`), `shop_item` = VALUES(`shop_item`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `type` = VALUES(`type`), `name` = VALUES(`name`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `vip_privileges` (`id`, `vip_id`, `shop_item`, `icon`, `state`, `type`, `name`, `sort_order`) VALUES (206, 2, NULL, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_2/privileges/vip_2_privilege_6.png', 9, 6, 'Exclusive Customer Service', 6) ON DUPLICATE KEY UPDATE `vip_id` = VALUES(`vip_id`), `shop_item` = VALUES(`shop_item`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `type` = VALUES(`type`), `name` = VALUES(`name`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `vip_privileges` (`id`, `vip_id`, `shop_item`, `icon`, `state`, `type`, `name`, `sort_order`) VALUES (207, 2, NULL, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_2/privileges/vip_2_privilege_7.png', 9, 7, 'Follow Num', 7) ON DUPLICATE KEY UPDATE `vip_id` = VALUES(`vip_id`), `shop_item` = VALUES(`shop_item`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `type` = VALUES(`type`), `name` = VALUES(`name`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `vip_privileges` (`id`, `vip_id`, `shop_item`, `icon`, `state`, `type`, `name`, `sort_order`) VALUES (208, 2, NULL, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_2/privileges/vip_2_privilege_8.png', 9, 8, 'Frame', 8) ON DUPLICATE KEY UPDATE `vip_id` = VALUES(`vip_id`), `shop_item` = VALUES(`shop_item`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `type` = VALUES(`type`), `name` = VALUES(`name`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `vip_privileges` (`id`, `vip_id`, `shop_item`, `icon`, `state`, `type`, `name`, `sort_order`) VALUES (301, 3, NULL, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_3/privileges/vip_3_privilege_1.png', 9, 1, 'Broadcast', 1) ON DUPLICATE KEY UPDATE `vip_id` = VALUES(`vip_id`), `shop_item` = VALUES(`shop_item`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `type` = VALUES(`type`), `name` = VALUES(`name`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `vip_privileges` (`id`, `vip_id`, `shop_item`, `icon`, `state`, `type`, `name`, `sort_order`) VALUES (302, 3, NULL, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_3/privileges/vip_3_privilege_2.png', 9, 2, 'Business Card', 2) ON DUPLICATE KEY UPDATE `vip_id` = VALUES(`vip_id`), `shop_item` = VALUES(`shop_item`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `type` = VALUES(`type`), `name` = VALUES(`name`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `vip_privileges` (`id`, `vip_id`, `shop_item`, `icon`, `state`, `type`, `name`, `sort_order`) VALUES (303, 3, NULL, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_3/privileges/vip_3_privilege_3.png', 9, 3, 'Entry', 3) ON DUPLICATE KEY UPDATE `vip_id` = VALUES(`vip_id`), `shop_item` = VALUES(`shop_item`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `type` = VALUES(`type`), `name` = VALUES(`name`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `vip_privileges` (`id`, `vip_id`, `shop_item`, `icon`, `state`, `type`, `name`, `sort_order`) VALUES (304, 3, NULL, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_3/privileges/vip_3_privilege_4.png', 9, 4, 'Emoji', 4) ON DUPLICATE KEY UPDATE `vip_id` = VALUES(`vip_id`), `shop_item` = VALUES(`shop_item`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `type` = VALUES(`type`), `name` = VALUES(`name`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `vip_privileges` (`id`, `vip_id`, `shop_item`, `icon`, `state`, `type`, `name`, `sort_order`) VALUES (305, 3, NULL, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_3/privileges/vip_3_privilege_5.png', 9, 5, 'Entry Effect', 5) ON DUPLICATE KEY UPDATE `vip_id` = VALUES(`vip_id`), `shop_item` = VALUES(`shop_item`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `type` = VALUES(`type`), `name` = VALUES(`name`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `vip_privileges` (`id`, `vip_id`, `shop_item`, `icon`, `state`, `type`, `name`, `sort_order`) VALUES (306, 3, NULL, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_3/privileges/vip_3_privilege_6.png', 9, 6, 'Exclusive Customer Service', 6) ON DUPLICATE KEY UPDATE `vip_id` = VALUES(`vip_id`), `shop_item` = VALUES(`shop_item`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `type` = VALUES(`type`), `name` = VALUES(`name`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `vip_privileges` (`id`, `vip_id`, `shop_item`, `icon`, `state`, `type`, `name`, `sort_order`) VALUES (307, 3, NULL, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_3/privileges/vip_3_privilege_7.png', 9, 7, 'Follow Num', 7) ON DUPLICATE KEY UPDATE `vip_id` = VALUES(`vip_id`), `shop_item` = VALUES(`shop_item`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `type` = VALUES(`type`), `name` = VALUES(`name`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `vip_privileges` (`id`, `vip_id`, `shop_item`, `icon`, `state`, `type`, `name`, `sort_order`) VALUES (308, 3, NULL, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_3/privileges/vip_3_privilege_8.png', 9, 8, 'Frame', 8) ON DUPLICATE KEY UPDATE `vip_id` = VALUES(`vip_id`), `shop_item` = VALUES(`shop_item`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `type` = VALUES(`type`), `name` = VALUES(`name`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `vip_privileges` (`id`, `vip_id`, `shop_item`, `icon`, `state`, `type`, `name`, `sort_order`) VALUES (309, 3, NULL, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_3/privileges/vip_3_privilege_9.png', 9, 9, 'Gift', 9) ON DUPLICATE KEY UPDATE `vip_id` = VALUES(`vip_id`), `shop_item` = VALUES(`shop_item`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `type` = VALUES(`type`), `name` = VALUES(`name`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `vip_privileges` (`id`, `vip_id`, `shop_item`, `icon`, `state`, `type`, `name`, `sort_order`) VALUES (310, 3, NULL, 'https://your-domain.com/uploads/appchat_seed_assets/vip/vip_3/privileges/vip_3_privilege_10.png', 9, 10, 'Highlight', 10) ON DUPLICATE KEY UPDATE `vip_id` = VALUES(`vip_id`), `shop_item` = VALUES(`shop_item`), `icon` = VALUES(`icon`), `state` = VALUES(`state`), `type` = VALUES(`type`), `name` = VALUES(`name`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `rocket_levels` (`id`, `lvl`, `name`, `score`, `icon`, `global`, `anim`, `icon_anim`, `state`) VALUES (1, 1, 'Rocket Level 1', 1000, 'https://your-domain.com/uploads/appchat_seed_assets/rockets/rocket_icon_1.png', 'https://your-domain.com/uploads/appchat_seed_assets/rockets/rocket_global_1.webp', 'https://your-domain.com/uploads/appchat_seed_assets/rockets/rocket_anim_1.svga', 'https://your-domain.com/uploads/appchat_seed_assets/rockets/rocket_icon_anim_1.webp', 9) ON DUPLICATE KEY UPDATE `lvl` = VALUES(`lvl`), `name` = VALUES(`name`), `score` = VALUES(`score`), `icon` = VALUES(`icon`), `global` = VALUES(`global`), `anim` = VALUES(`anim`), `icon_anim` = VALUES(`icon_anim`), `state` = VALUES(`state`);
INSERT INTO `rocket_levels` (`id`, `lvl`, `name`, `score`, `icon`, `global`, `anim`, `icon_anim`, `state`) VALUES (2, 2, 'Rocket Level 2', 10000, 'https://your-domain.com/uploads/appchat_seed_assets/rockets/rocket_icon_2.png', 'https://your-domain.com/uploads/appchat_seed_assets/rockets/rocket_global_2.webp', 'https://your-domain.com/uploads/appchat_seed_assets/rockets/rocket_anim_2.svga', 'https://your-domain.com/uploads/appchat_seed_assets/rockets/rocket_icon_anim_2.webp', 9) ON DUPLICATE KEY UPDATE `lvl` = VALUES(`lvl`), `name` = VALUES(`name`), `score` = VALUES(`score`), `icon` = VALUES(`icon`), `global` = VALUES(`global`), `anim` = VALUES(`anim`), `icon_anim` = VALUES(`icon_anim`), `state` = VALUES(`state`);
INSERT INTO `rocket_levels` (`id`, `lvl`, `name`, `score`, `icon`, `global`, `anim`, `icon_anim`, `state`) VALUES (3, 3, 'Rocket Level 3', 30000, 'https://your-domain.com/uploads/appchat_seed_assets/rockets/rocket_icon_3.png', 'https://your-domain.com/uploads/appchat_seed_assets/rockets/rocket_global_3.webp', 'https://your-domain.com/uploads/appchat_seed_assets/rockets/rocket_anim_3.svga', 'https://your-domain.com/uploads/appchat_seed_assets/rockets/rocket_icon_anim_3.webp', 9) ON DUPLICATE KEY UPDATE `lvl` = VALUES(`lvl`), `name` = VALUES(`name`), `score` = VALUES(`score`), `icon` = VALUES(`icon`), `global` = VALUES(`global`), `anim` = VALUES(`anim`), `icon_anim` = VALUES(`icon_anim`), `state` = VALUES(`state`);

-- Included room backgrounds
INSERT INTO `media_assets` (`id`, `type`, `name`, `url`, `state`, `sort_order`) VALUES (40, 'room_bg', 'Room Background 40', 'https://your-domain.com/uploads/appchat_seed_assets/room_bgs/40_bg.jpg', 9, 1) ON DUPLICATE KEY UPDATE `type` = VALUES(`type`), `name` = VALUES(`name`), `url` = VALUES(`url`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `media_assets` (`id`, `type`, `name`, `url`, `state`, `sort_order`) VALUES (41, 'room_bg', 'Room Background 41', 'https://your-domain.com/uploads/appchat_seed_assets/room_bgs/41_bg.jpeg', 9, 2) ON DUPLICATE KEY UPDATE `type` = VALUES(`type`), `name` = VALUES(`name`), `url` = VALUES(`url`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `media_assets` (`id`, `type`, `name`, `url`, `state`, `sort_order`) VALUES (42, 'room_bg', 'Room Background 42', 'https://your-domain.com/uploads/appchat_seed_assets/room_bgs/42_bg.jpeg', 9, 3) ON DUPLICATE KEY UPDATE `type` = VALUES(`type`), `name` = VALUES(`name`), `url` = VALUES(`url`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `media_assets` (`id`, `type`, `name`, `url`, `state`, `sort_order`) VALUES (43, 'room_bg', 'Room Background 43', 'https://your-domain.com/uploads/appchat_seed_assets/room_bgs/43_bg.jpeg', 9, 4) ON DUPLICATE KEY UPDATE `type` = VALUES(`type`), `name` = VALUES(`name`), `url` = VALUES(`url`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);
INSERT INTO `media_assets` (`id`, `type`, `name`, `url`, `state`, `sort_order`) VALUES (44, 'room_bg', 'Room Background 44', 'https://your-domain.com/uploads/appchat_seed_assets/room_bgs/44_bg.jpeg', 9, 5) ON DUPLICATE KEY UPDATE `type` = VALUES(`type`), `name` = VALUES(`name`), `url` = VALUES(`url`), `state` = VALUES(`state`), `sort_order` = VALUES(`sort_order`);

-- Included user level progressions
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (101, 'gifter', 1, 0, 'https://your-domain.com/uploads/appchat_seed_assets/levels/gifter/level_1.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (102, 'gifter', 2, 1500, 'https://your-domain.com/uploads/appchat_seed_assets/levels/gifter/level_2.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (103, 'gifter', 3, 6000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/gifter/level_3.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (104, 'gifter', 4, 13500, 'https://your-domain.com/uploads/appchat_seed_assets/levels/gifter/level_4.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (105, 'gifter', 5, 24000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/gifter/level_5.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (106, 'gifter', 6, 37500, 'https://your-domain.com/uploads/appchat_seed_assets/levels/gifter/level_6.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (107, 'gifter', 7, 54000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/gifter/level_7.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (108, 'gifter', 8, 73500, 'https://your-domain.com/uploads/appchat_seed_assets/levels/gifter/level_8.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (109, 'gifter', 9, 96000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/gifter/level_9.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (110, 'gifter', 10, 121500, 'https://your-domain.com/uploads/appchat_seed_assets/levels/gifter/level_10.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (111, 'gifter', 11, 150000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/gifter/level_11.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (112, 'gifter', 12, 181500, 'https://your-domain.com/uploads/appchat_seed_assets/levels/gifter/level_12.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (113, 'gifter', 13, 216000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/gifter/level_13.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (114, 'gifter', 14, 253500, 'https://your-domain.com/uploads/appchat_seed_assets/levels/gifter/level_14.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (115, 'gifter', 15, 294000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/gifter/level_15.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (116, 'gifter', 16, 337500, 'https://your-domain.com/uploads/appchat_seed_assets/levels/gifter/level_16.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (117, 'gifter', 17, 384000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/gifter/level_17.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (118, 'gifter', 18, 433500, 'https://your-domain.com/uploads/appchat_seed_assets/levels/gifter/level_18.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (119, 'gifter', 19, 486000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/gifter/level_19.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (120, 'gifter', 20, 541500, 'https://your-domain.com/uploads/appchat_seed_assets/levels/gifter/level_20.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (201, 'anchor', 1, 0, 'https://your-domain.com/uploads/appchat_seed_assets/levels/anchor/level_1.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (202, 'anchor', 2, 1000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/anchor/level_2.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (203, 'anchor', 3, 4000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/anchor/level_3.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (204, 'anchor', 4, 9000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/anchor/level_4.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (205, 'anchor', 5, 16000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/anchor/level_5.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (206, 'anchor', 6, 25000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/anchor/level_6.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (207, 'anchor', 7, 36000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/anchor/level_7.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (208, 'anchor', 8, 49000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/anchor/level_8.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (209, 'anchor', 9, 64000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/anchor/level_9.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (210, 'anchor', 10, 81000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/anchor/level_10.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (211, 'anchor', 11, 100000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/anchor/level_11.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (212, 'anchor', 12, 121000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/anchor/level_12.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (213, 'anchor', 13, 144000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/anchor/level_13.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (214, 'anchor', 14, 169000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/anchor/level_14.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (215, 'anchor', 15, 196000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/anchor/level_15.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (216, 'anchor', 16, 225000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/anchor/level_16.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (217, 'anchor', 17, 256000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/anchor/level_17.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (218, 'anchor', 18, 289000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/anchor/level_18.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (219, 'anchor', 19, 324000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/anchor/level_19.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (220, 'anchor', 20, 361000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/anchor/level_20.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (301, 'charge', 1, 0, 'https://your-domain.com/uploads/appchat_seed_assets/levels/charge/level_1.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (302, 'charge', 2, 2500, 'https://your-domain.com/uploads/appchat_seed_assets/levels/charge/level_2.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (303, 'charge', 3, 10000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/charge/level_3.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (304, 'charge', 4, 22500, 'https://your-domain.com/uploads/appchat_seed_assets/levels/charge/level_4.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (305, 'charge', 5, 40000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/charge/level_5.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (306, 'charge', 6, 62500, 'https://your-domain.com/uploads/appchat_seed_assets/levels/charge/level_6.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (307, 'charge', 7, 90000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/charge/level_7.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (308, 'charge', 8, 122500, 'https://your-domain.com/uploads/appchat_seed_assets/levels/charge/level_8.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (309, 'charge', 9, 160000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/charge/level_9.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (310, 'charge', 10, 202500, 'https://your-domain.com/uploads/appchat_seed_assets/levels/charge/level_10.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (311, 'charge', 11, 250000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/charge/level_11.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (312, 'charge', 12, 302500, 'https://your-domain.com/uploads/appchat_seed_assets/levels/charge/level_12.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (313, 'charge', 13, 360000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/charge/level_13.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (314, 'charge', 14, 422500, 'https://your-domain.com/uploads/appchat_seed_assets/levels/charge/level_14.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (315, 'charge', 15, 490000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/charge/level_15.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (316, 'charge', 16, 562500, 'https://your-domain.com/uploads/appchat_seed_assets/levels/charge/level_16.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (317, 'charge', 17, 640000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/charge/level_17.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (318, 'charge', 18, 722500, 'https://your-domain.com/uploads/appchat_seed_assets/levels/charge/level_18.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (319, 'charge', 19, 810000, 'https://your-domain.com/uploads/appchat_seed_assets/levels/charge/level_19.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);
INSERT INTO `levels` (`id`, `type`, `lvl`, `points`, `icon`, `privileges`, `created_at`) VALUES (320, 'charge', 20, 902500, 'https://your-domain.com/uploads/appchat_seed_assets/levels/charge/level_20.png', '{}', UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE `points` = VALUES(`points`), `icon` = VALUES(`icon`), `privileges` = VALUES(`privileges`);


-- AppChat curated marketplace seed data.
-- Default admin dashboard password: admin@12345. Mobile demo testing uses Google Sign-In.
SET FOREIGN_KEY_CHECKS=0;

DELETE FROM user_tokens;
DELETE FROM room_seats;
DELETE FROM room_members;
DELETE FROM rooms;
DELETE FROM cash_accounts;
DELETE FROM wallet_transactions;
DELETE FROM payment_logs;
DELETE FROM recharge_requests;
DELETE FROM user_relations;
DELETE FROM users;

INSERT INTO users (id, username, name, email, password_hash, pos, role, type, state, avatar, country, coins, diamond, dollar_earnings, total_points, gifter_points_total, anchor_points_total, recharge_points_total, followers_count, following_count, language, created_at, updated_at) VALUES
(1, 'demo_admin_user', 'Demo Admin User', 'admin.user@example.com', '$2y$10$9DRAtde/UoMlJn0oJfmUJuT0tqT2UB7vPZ.2qtK7j40iS2.hqtq3a', 1, 9, 1, 9, 'https://your-domain.com/uploads/demo/avatar-admin.png', 'US', 50000, 2500, 0.00000000, 12000, 5000, 3000, 4000, 2, 1, 'en', UTC_TIMESTAMP(), UTC_TIMESTAMP()),
(2, 'demo_alex', 'Alex Demo', 'alex.demo@example.com', '$2y$10$9DRAtde/UoMlJn0oJfmUJuT0tqT2UB7vPZ.2qtK7j40iS2.hqtq3a', 3, 5, 1, 9, 'https://your-domain.com/uploads/demo/avatar-alex.png', 'US', 35000, 1200, 0.00000000, 8000, 3200, 2200, 2600, 1, 2, 'en', UTC_TIMESTAMP(), UTC_TIMESTAMP()),
(3, 'demo_sophia', 'Sophia Demo', 'sophia.demo@example.com', '$2y$10$9DRAtde/UoMlJn0oJfmUJuT0tqT2UB7vPZ.2qtK7j40iS2.hqtq3a', 3, 5, 2, 9, 'https://your-domain.com/uploads/demo/avatar-sophia.png', 'GB', 25000, 900, 0.00000000, 6000, 2400, 1800, 1800, 1, 1, 'en', UTC_TIMESTAMP(), UTC_TIMESTAMP());


INSERT INTO recharge_packages (id, product_id, android_product_id, ios_product_id, name, coins, diamonds, usd_price, state, sort_order) VALUES
(1, 'appchat_coins_1000', 'appchat_coins_1000', 'appchat_coins_1000_ios', '1,000 Coins', 1000, 0, 0.99, 9, 1),
(2, 'appchat_coins_5000', 'appchat_coins_5000', 'appchat_coins_5000_ios', '5,000 Coins', 5000, 0, 4.99, 9, 2),
(3, 'appchat_coins_12000', 'appchat_coins_12000', 'appchat_coins_12000_ios', '12,000 Coins', 12000, 0, 9.99, 9, 3);


INSERT INTO app_settings (setting_key, group_key, setting_value, is_secret, updated_at) VALUES
('firebase_project_id', 'notifications', '', 0, UTC_TIMESTAMP()),
('firebase_service_account_json', 'notifications', '', 1, UTC_TIMESTAMP()),
('google_play_package_name', 'payments', 'com.appchat.live', 0, UTC_TIMESTAMP()),
('google_play_service_account_json', 'payments', '', 1, UTC_TIMESTAMP()),
('image_storage_driver', 'uploads', 'server', 0, UTC_TIMESTAMP())
ON DUPLICATE KEY UPDATE setting_value=VALUES(setting_value), is_secret=VALUES(is_secret), updated_at=VALUES(updated_at);

SET FOREIGN_KEY_CHECKS=1;

-- Shared HTML-game foundation (new installs only).
-- Apply once before deploying. Existing logins obtain web_token on their next login.
ALTER TABLE user_tokens
  ADD COLUMN web_token CHAR(64) CHARACTER SET ascii COLLATE ascii_bin NULL,
  ADD UNIQUE KEY uq_user_web_token (web_token);

-- Reuse the existing ledger; NULL keys leave all legacy transactions unaffected.
ALTER TABLE wallet_transactions
  ADD COLUMN gid BIGINT UNSIGNED NULL,
  ADD COLUMN html_operation_ref VARCHAR(96) CHARACTER SET ascii COLLATE ascii_bin NULL,
  ADD COLUMN html_idempotency_key VARCHAR(96) CHARACTER SET ascii COLLATE ascii_bin NULL,
  ADD COLUMN html_fingerprint CHAR(64) CHARACTER SET ascii COLLATE ascii_bin NULL,
  ADD COLUMN balance_after BIGINT NULL,
  ADD UNIQUE KEY uq_html_retry (uid, html_idempotency_key),
  ADD UNIQUE KEY uq_html_operation (uid, gid, html_operation_ref, type),
  ADD CONSTRAINT fk_wallet_game FOREIGN KEY (gid) REFERENCES games(id) ON DELETE RESTRICT;

INSERT IGNORE INTO app_settings (setting_key, group_key, setting_value, is_secret, updated_at)
VALUES ('html_games_platform_profit_percent', 'html_games', '10.00', 0, UTC_TIMESTAMP());
INSERT IGNORE INTO admin_permissions (module, action, slug, name, description, created_at)
VALUES ('settings', 'games_profit', 'settings.games_profit', 'Set HTML games target profit', 'Owner control of target long-run platform share; not a per-round fee.', UTC_TIMESTAMP());
INSERT IGNORE INTO admin_role_permissions (role_id, permission_id)
SELECT r.id, p.id FROM admin_roles r JOIN admin_permissions p ON p.slug = 'settings.games_profit' WHERE r.slug = 'super_admin';

-- Separate cash agencies; legacy agencies and agency_id continue to represent families.
CREATE TABLE IF NOT EXISTS recharge_agencies (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  uid BIGINT UNSIGNED NOT NULL UNIQUE,
  name VARCHAR(120) NOT NULL,
  country_code VARCHAR(4) NOT NULL,
  phone VARCHAR(20) NOT NULL,
  image VARCHAR(500) NOT NULL,
  coins_balance BIGINT UNSIGNED NOT NULL DEFAULT 0,
  usd_balance DECIMAL(18,8) UNSIGNED NOT NULL DEFAULT 0,
  state TINYINT NOT NULL DEFAULT 9,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS recharge_agency_logs (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  agency_id BIGINT UNSIGNED NOT NULL,
  type VARCHAR(40) NOT NULL,
  currency VARCHAR(10) NOT NULL,
  amount DECIMAL(23,8) NOT NULL,
  actor_id BIGINT UNSIGNED NOT NULL,
  operation_key VARCHAR(100) NOT NULL,
  target_uid BIGINT UNSIGNED NULL,
  withdrawal_request_id BIGINT UNSIGNED NULL,
  coins_balance BIGINT UNSIGNED NOT NULL,
  usd_balance DECIMAL(18,8) UNSIGNED NOT NULL,
  created_at DATETIME NOT NULL,
  UNIQUE KEY uq_cash_agency_operation (agency_id, operation_key),
  UNIQUE KEY uq_cash_agency_delivery (withdrawal_request_id, type),
  INDEX idx_cash_agency_history (agency_id,id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

SET @sql = IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='users' AND COLUMN_NAME='recharge_agency_id')=0, 'ALTER TABLE users ADD COLUMN recharge_agency_id BIGINT UNSIGNED NULL, ADD UNIQUE KEY uq_user_recharge_agency (recharge_agency_id)', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @sql = IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='recharge_requests' AND COLUMN_NAME='recharge_agency_id')=0, 'ALTER TABLE recharge_requests ADD COLUMN recharge_agency_id BIGINT UNSIGNED NULL, ADD INDEX idx_cash_agency_requests (recharge_agency_id,status,id)', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @sql = IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='wallet_transactions' AND COLUMN_NAME='recharge_agency_id')=0, 'ALTER TABLE wallet_transactions ADD COLUMN recharge_agency_id BIGINT UNSIGNED NULL, ADD INDEX idx_wallet_cash_agency (recharge_agency_id,id)', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @sql = IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='wallet_transactions' AND COLUMN_NAME='withdrawal_request_id')=0, 'ALTER TABLE wallet_transactions ADD COLUMN withdrawal_request_id BIGINT UNSIGNED NULL, ADD UNIQUE KEY uq_wallet_withdrawal_request (withdrawal_request_id)', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
