-- Adisy10 Backoffice - Platform Bağlantıları (Multi-connection)
-- Her satır = restoranın bir platformdaki bir hesabı (örn: Getir xx1 / xx2)

CREATE TABLE IF NOT EXISTS restaurant_platform_connections (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,

  restaurant_id BIGINT UNSIGNED NOT NULL,

  platform VARCHAR(32) NOT NULL, -- getir, trendyol, yemeksepeti
  connection_name VARCHAR(100) NULL, -- xx1 / xx2 gibi

  external_restaurant_id VARCHAR(64) NOT NULL, -- Getir restaurant id / Trendyol seller id vb.
  restaurant_secret_key VARCHAR(128) NOT NULL,

  is_active TINYINT(1) NOT NULL DEFAULT 1,

  created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

  INDEX idx_restaurant (restaurant_id),
  INDEX idx_platform (platform),

  UNIQUE KEY uniq_platform_external (platform, external_restaurant_id)
);
