-- Müşteri vitrin oturumları (admin oturumundan ayrı token).
-- idempotent

CREATE TABLE IF NOT EXISTS shop_sessions (
  id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  token CHAR(64) NOT NULL,
  shop_customer_id BIGINT UNSIGNED NOT NULL,
  expires_at DATETIME NOT NULL,
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (id),
  UNIQUE KEY uq_shop_sessions_token (token),
  KEY idx_shop_sessions_customer (shop_customer_id),
  KEY idx_shop_sessions_expires (expires_at),
  CONSTRAINT fk_shop_sessions_customer FOREIGN KEY (shop_customer_id) REFERENCES shop_customers(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
