SET NAMES utf8mb4;

CREATE TABLE IF NOT EXISTS editorial_calendar_events (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  workspace_id BIGINT UNSIGNED NOT NULL,
  scheduled_post_id BIGINT UNSIGNED NOT NULL,
  action ENUM('move') NOT NULL,
  new_scheduled_at DATETIME NULL,
  created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  INDEX idx_ece_post_time(scheduled_post_id,created_at),
  CONSTRAINT fk_ece_workspace FOREIGN KEY(workspace_id) REFERENCES workspaces(id) ON DELETE CASCADE,
  CONSTRAINT fk_ece_post FOREIGN KEY(scheduled_post_id) REFERENCES scheduled_posts(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
