-- Sipariş durum zaman çizelgesi (mevcut kurulumlarda bir kez çalıştırın).
CREATE TABLE IF NOT EXISTS ecommerce_order_events (
  id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  order_id BIGINT UNSIGNED NOT NULL,
  from_status VARCHAR(32) NOT NULL,
  to_status VARCHAR(32) NOT NULL,
  source VARCHAR(32) NOT NULL DEFAULT 'system',
  note VARCHAR(255) NULL DEFAULT NULL,
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (id),
  KEY idx_ecommerce_order_events_order (order_id),
  CONSTRAINT fk_ecommerce_order_events_order FOREIGN KEY (order_id) REFERENCES ecommerce_orders(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
