-- +goose Up
CREATE TABLE IF NOT EXISTS file_status_realtime_events (
  id BINARY(16) NOT NULL,
  file_id BINARY(16) NOT NULL,
  user_id BINARY(16) NOT NULL,
  status VARCHAR(32) NOT NULL,
  name VARCHAR(255) NOT NULL,
  failure_reason TEXT NULL,
  occurred_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
  delivered_at DATETIME(6) NULL,
  created_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
  updated_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
  PRIMARY KEY (id),
  KEY idx_file_status_realtime_events_file (file_id),
  KEY idx_file_status_realtime_events_user (user_id),
  KEY idx_file_status_realtime_events_status (status),
  KEY idx_file_status_realtime_events_occurred (occurred_at),
  KEY idx_file_status_realtime_events_delivered (delivered_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- +goose Down
DROP TABLE IF EXISTS file_status_realtime_events;
