-- MySQL 크리에이터 랭킹 스냅샷 테이블 -- 날짜/시간 표시 컬럼은 TIMESTAMP를 사용한다. -- 같은 기간 재생성 시 삭제 기준: -- delete from creator_ranking_snapshot -- where aggregation_start_at_utc = :aggregationStartAtUtc -- and aggregation_end_at_utc = :aggregationEndAtUtc; create table creator_ranking_snapshot ( id bigint not null auto_increment comment '크리에이터 랭킹 스냅샷 ID', aggregation_start_at_utc timestamp not null comment '집계 시작 시각(UTC, 포함)', aggregation_end_at_utc timestamp not null comment '집계 종료 시각(UTC, 미포함)', creator_id bigint not null comment '크리에이터 회원 ID(member.id)', nickname varchar(100) not null comment '스냅샷 생성 시점 크리에이터 닉네임', profile_image_url varchar(500) null comment '스냅샷 생성 시점 크리에이터 프로필 이미지 URL', final_score double not null comment '최종 랭킹 점수', content_live_score double not null comment '콘텐츠/라이브 카테고리 점수', engagement_score double not null comment '참여 반응 카테고리 점수', support_score double not null comment '응원 카테고리 점수', fan_loyalty_score double not null comment '팬 충성도 카테고리 점수', live_can_amount bigint not null comment '라이브 계열 사용 캔 합계', content_purchase_can_amount bigint not null comment '콘텐츠 구매 사용 캔 합계', content_like_count bigint not null comment '콘텐츠 좋아요 수', content_comment_count bigint not null comment '콘텐츠 댓글 및 대댓글 수', channel_donation_can_amount bigint not null comment '채널 후원 사용 캔 합계', channel_donation_count bigint not null comment '채널 후원 건수', fan_talk_count bigint not null comment '최상위 팬 Talk 수', final_follower_count bigint not null comment '집계 종료 시점 활성 팔로우 수', follow_increase bigint not 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='크리에이터 랭킹 주간 스냅샷'; create index idx_creator_ranking_snapshot_period_score on creator_ranking_snapshot (aggregation_end_at_utc, final_score desc); create index idx_creator_ranking_snapshot_replace_period on creator_ranking_snapshot (aggregation_start_at_utc, aggregation_end_at_utc); 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);