diff --git a/docs/20260608_크리에이터_랭킹/create-ranking-tables.sql b/docs/20260608_크리에이터_랭킹/create-ranking-tables.sql index a942a5ef..49d77902 100644 --- a/docs/20260608_크리에이터_랭킹/create-ranking-tables.sql +++ b/docs/20260608_크리에이터_랭킹/create-ranking-tables.sql @@ -39,3 +39,23 @@ create index idx_creator_ranking_snapshot_replace_period create index idx_creator_ranking_snapshot_period_creator on creator_ranking_snapshot (aggregation_start_at_utc, aggregation_end_at_utc, creator_id); + +create table creator_ranking_snapshot_job ( + id bigint not null auto_increment comment '크리에이터 랭킹 스냅샷 생성 job ID', + aggregation_start_at_utc timestamp not null comment '집계 시작 시각(UTC, 포함)', + aggregation_end_at_utc timestamp not null comment '집계 종료 시각(UTC, 미포함)', + trigger_type varchar(20) not null comment '실행 트리거(SCHEDULED, MANUAL)', + status varchar(20) not null comment 'job 상태(PENDING, PROCESSING, DONE, FAILED)', + last_error text null comment '마지막 실패 사유', + processing_started_at timestamp null comment '처리 시작 시각', + processed_at timestamp null comment '처리 완료 시각', + created_at timestamp not null default current_timestamp comment '생성 시각', + updated_at timestamp not null default current_timestamp on update current_timestamp comment '수정 시각', + primary key (id) +) engine=InnoDB default charset=utf8mb4 comment='크리에이터 랭킹 스냅샷 생성 job 이력'; + +create index idx_creator_ranking_snapshot_job_period_status + on creator_ranking_snapshot_job (aggregation_start_at_utc, aggregation_end_at_utc, status); + +create index idx_creator_ranking_snapshot_job_status_created_at + on creator_ranking_snapshot_job (status, created_at);