-- +goose Up
CREATE TABLE IF NOT EXISTS file_upload_intents (
  id BINARY(16) NOT NULL,
  name VARCHAR(255) NOT NULL,
  name_normalized VARCHAR(255) NOT NULL,
  extension VARCHAR(32) NULL,
  size_bytes BIGINT UNSIGNED NOT NULL DEFAULT 0,
  mime_type VARCHAR(255) NOT NULL,
  bucket VARCHAR(128) NOT NULL,
  object_key VARCHAR(512) NOT NULL,
  status VARCHAR(32) NOT NULL DEFAULT 'pending',
  expires_at DATETIME(6) NOT NULL,
  completed_at DATETIME(6) NULL,
  created_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
  created_by BINARY(16) NULL,
  updated_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
  updated_by BINARY(16) NULL,
  PRIMARY KEY (id),
  UNIQUE KEY uq_file_upload_intents_object_key (object_key),
  KEY idx_file_upload_intents_status (status),
  KEY idx_file_upload_intents_expires_at (expires_at),
  KEY idx_file_upload_intents_completed_at (completed_at),
  KEY idx_file_upload_intents_created_by (created_by)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- +goose Down
DROP TABLE IF EXISTS file_upload_intents;
