Compare commits

...

2 Commits

Author SHA1 Message Date
zerosaturation
ffa53f854c docker: 修改配置 2026-05-18 20:22:00 +08:00
zerosaturation
602b615dc5 docker: 修改配置 2026-05-18 20:21:32 +08:00
15 changed files with 51 additions and 1469 deletions

2
.gitignore vendored
View File

@ -10,3 +10,5 @@ node_modules
package-lock.json
# Added by code-review-graph
.code-review-graph/
.claude

View File

@ -5,11 +5,11 @@
# Usage: docker-compose -f docker-compose.prod.yml --profile prod up -d
# ===================================================================
# Database - MUST CHANGE
DB_PASSWORD=CHANGE_ME_TO_A_SECURE_PASSWORD
# Database
DB_PASSWORD=postgres123
# JWT Secret - MUST CHANGE
JWT_SECRET=CHANGE_ME_TO_A_VERY_LONG_RANDOM_STRING
# JWT Secret
JWT_SECRET=topfans-secret-key-please-change-in-production
# OSS Configuration
OSS_REGION=cn-shanghai
@ -27,4 +27,6 @@ MINIMAX_API_URL=https://api.minimaxi.com/v1/image_generation
# Redis Configuration
REDIS_HOST=topfans-redis
REDIS_PORT=6379
REDIS_PASSWORD=123456
REDIS_DB=0

View File

@ -58,26 +58,47 @@ services:
reservations:
memory: 128M
# ==================== Flyway Migration ====================
flyway:
image: flyway/flyway:10
container_name: topfans-flyway
restart: "no"
depends_on:
postgres:
condition: service_healthy
environment:
- FLYWAY_URL=jdbc:postgresql://postgres:5432/topfans
- FLYWAY_USER=postgres
- FLYWAY_PASSWORD=${DB_PASSWORD:-postgres123}
- FLYWAY_SCHEMAS=public
- FLYWAY_PLACEHOLDER_REPLACEMENT=true
volumes:
- ./sql/migrations:/flyway/sql
- flyway_data:/flyway/data
command: migrate -baselineOnMigrate=true
# ==================== Redis ====================
redis:
image: redis:latest
container_name: topfans-redis
restart: always
ports:
- "6379:6379"
networks:
- topfans-net
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 30s
timeout: 10s
retries: 5
deploy:
resources:
limits:
memory: 256M
reservations:
memory: 64M
# ==================== Flyway Migration ====================
# flyway:
# image: flyway/flyway:10
# container_name: topfans-flyway
# restart: "no"
# depends_on:
# postgres:
# condition: service_healthy
# environment:
# - FLYWAY_URL=jdbc:postgresql://postgres:5432/topfans
# - FLYWAY_USER=postgres
# - FLYWAY_PASSWORD=${DB_PASSWORD:-postgres123}
# - FLYWAY_SCHEMAS=public
# - FLYWAY_PLACEHOLDER_REPLACEMENT=true
# volumes:
# - ./sql/migrations:/flyway/sql
# - flyway_data:/flyway/data
# command: migrate -baselineOnMigrate=true
# networks:
# - topfans-net
# ==================== Dubbo Services ====================
userservice:
@ -97,8 +118,8 @@ services:
DB_PASSWORD: ${DB_PASSWORD:-postgres123}
DB_NAME: topfans
depends_on:
flyway:
condition: service_completed_successfully
postgres:
condition: service_healthy
networks:
- topfans-net
expose:

View File

@ -1,491 +0,0 @@
-- V1__init_schema.sql
-- 初始表结构
-- postgres 扩展
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- =====================================================
-- 用户相关表
-- =====================================================
-- 用户表
CREATE TABLE public.users (
id bigint NOT NULL,
mobile character varying(11) NOT NULL,
password_hash character varying(255) NOT NULL,
access_token text,
token_expires_at bigint,
avatar_url character varying(500),
global_wallet_address character varying(100),
is_active boolean DEFAULT true NOT NULL,
created_at bigint NOT NULL,
updated_at bigint NOT NULL,
deleted_at bigint
);
CREATE SEQUENCE public.users_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
ALTER TABLE ONLY public.users ADD CONSTRAINT users_pkey PRIMARY KEY (id);
CREATE UNIQUE INDEX uk_users_mobile ON public.users USING btree (mobile);
CREATE INDEX idx_users_deleted_at ON public.users USING btree (deleted_at);
ALTER TABLE ONLY public.users ADD CONSTRAINT fk_users FOREIGN KEY (owner_uid) REFERENCES public.users(id) ON DELETE CASCADE;
-- 明星信息表
CREATE TABLE public.stars (
star_id bigint NOT NULL,
name character varying(100) NOT NULL,
tag character varying(100),
name_en character varying(100),
pic_url character varying(500),
description text,
identity_id character varying(50) NOT NULL,
is_active boolean DEFAULT true NOT NULL,
created_at bigint NOT NULL,
updated_at bigint NOT NULL
);
CREATE SEQUENCE public.stars_star_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
ALTER TABLE ONLY public.stars ALTER COLUMN star_id SET DEFAULT nextval('public.stars_star_id_seq'::regclass);
ALTER TABLE ONLY public.stars ADD CONSTRAINT stars_pkey PRIMARY KEY (star_id);
CREATE UNIQUE INDEX uk_stars_identity_id ON public.stars USING btree (identity_id);
-- 粉丝档案表
CREATE TABLE public.fan_profiles (
id bigint NOT NULL,
user_id bigint NOT NULL,
star_id bigint NOT NULL,
nickname character varying(50) NOT NULL,
level integer DEFAULT 1 NOT NULL,
times integer DEFAULT 1 NOT NULL,
social integer DEFAULT 0 NOT NULL,
experience bigint DEFAULT 0 NOT NULL,
coin_balance bigint DEFAULT 0 NOT NULL,
crystal_balance bigint DEFAULT 0 NOT NULL,
tags jsonb,
starbook_limit integer DEFAULT 3 NOT NULL,
slot_limit integer DEFAULT 3 NOT NULL,
assets_count integer DEFAULT 0 NOT NULL,
chain_address character varying(100),
is_active boolean DEFAULT true NOT NULL,
created_at bigint NOT NULL,
updated_at bigint NOT NULL,
avatar_url character varying(500)
);
CREATE SEQUENCE public.fan_profiles_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
ALTER TABLE ONLY public.fan_profiles ALTER COLUMN id SET DEFAULT nextval('public.fan_profiles_id_seq'::regclass);
ALTER TABLE ONLY public.fan_profiles ADD CONSTRAINT fan_profiles_pkey PRIMARY KEY (id);
CREATE UNIQUE INDEX uk_fan_profiles_user_star ON public.fan_profiles USING btree (user_id, star_id);
CREATE UNIQUE INDEX uk_fan_profiles_star_nickname ON public.fan_profiles USING btree (star_id, nickname);
CREATE INDEX idx_fan_profiles_user_id ON public.fan_profiles USING btree (user_id);
CREATE INDEX idx_fan_profiles_star_id ON public.fan_profiles USING btree (star_id);
ALTER TABLE ONLY public.fan_profiles ADD CONSTRAINT fk_fan_profiles_user FOREIGN KEY (user_id) REFERENCES public.users(id);
ALTER TABLE ONLY public.fan_profiles ADD CONSTRAINT fk_fan_profiles_star FOREIGN KEY (star_id) REFERENCES public.stars(star_id);
-- =====================================================
-- 藏品相关表
-- =====================================================
-- 资产表(藏品)
CREATE TABLE public.assets (
id bigint NOT NULL,
owner_uid bigint NOT NULL,
star_id bigint NOT NULL,
name character varying(100) NOT NULL,
cover_url character varying(500) NOT NULL,
material_url character varying(500),
description text,
rarity integer,
tags jsonb,
visibility character varying(20) DEFAULT 'private'::character varying,
status integer DEFAULT 0 NOT NULL,
tx_hash character varying(100),
block_number bigint,
like_count integer DEFAULT 0 NOT NULL,
is_original boolean DEFAULT false NOT NULL,
created_at bigint NOT NULL,
updated_at bigint NOT NULL,
minted_at bigint,
deleted_at bigint,
is_active boolean DEFAULT true NOT NULL,
info text
);
CREATE SEQUENCE public.assets_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
ALTER TABLE ONLY public.assets ALTER COLUMN id SET DEFAULT nextval('public.assets_id_seq'::regclass);
ALTER TABLE ONLY public.assets ADD CONSTRAINT assets_pkey PRIMARY KEY (id);
CREATE INDEX idx_assets_created_at ON public.assets USING btree (created_at DESC);
CREATE INDEX idx_assets_deleted_at ON public.assets USING btree (deleted_at);
CREATE INDEX idx_assets_owner_star ON public.assets USING btree (owner_uid, star_id);
CREATE INDEX idx_assets_star_active ON public.assets USING btree (star_id, is_active);
CREATE INDEX idx_assets_status ON public.assets USING btree (status);
CREATE INDEX idx_assets_tx_hash ON public.assets USING btree (tx_hash);
ALTER TABLE ONLY public.assets ADD CONSTRAINT fk_assets_owner FOREIGN KEY (owner_uid) REFERENCES public.users(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.assets ADD CONSTRAINT fk_assets_star FOREIGN KEY (star_id) REFERENCES public.stars(star_id) ON DELETE CASCADE;
-- 资产注册表(星册体系)
CREATE TABLE public.asset_registry (
id bigint NOT NULL,
asset_id bigint NOT NULL,
asset_type character varying(20) NOT NULL,
owner_uid bigint NOT NULL,
star_id bigint NOT NULL,
grade integer,
collection_category character varying(50),
activity_id bigint,
activity_type character varying(50),
status integer DEFAULT 0 NOT NULL,
like_count integer DEFAULT 0 NOT NULL,
display_status integer DEFAULT 0 NOT NULL,
created_at bigint NOT NULL,
updated_at bigint NOT NULL
);
CREATE SEQUENCE public.asset_registry_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
ALTER TABLE ONLY public.asset_registry ALTER COLUMN id SET DEFAULT nextval('public.asset_registry_id_seq'::regclass);
ALTER TABLE ONLY public.asset_registry ADD CONSTRAINT asset_registry_pkey PRIMARY KEY (id);
CREATE INDEX idx_registry_owner_star ON public.asset_registry USING btree (owner_uid, star_id);
ALTER TABLE ONLY public.asset_registry ADD CONSTRAINT fk_registry_asset FOREIGN KEY (asset_id) REFERENCES public.assets(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.asset_registry ADD CONSTRAINT fk_registry_owner FOREIGN KEY (owner_uid) REFERENCES public.users(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.asset_registry ADD CONSTRAINT fk_registry_star FOREIGN KEY (star_id) REFERENCES public.stars(star_id) ON DELETE CASCADE;
-- 点赞记录表
CREATE TABLE public.asset_likes (
id bigint NOT NULL,
asset_id bigint NOT NULL,
user_id bigint NOT NULL,
star_id bigint NOT NULL,
created_at bigint NOT NULL
);
CREATE SEQUENCE public.asset_likes_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
ALTER TABLE ONLY public.asset_likes ALTER COLUMN id SET DEFAULT nextval('public.asset_likes_id_seq'::regclass);
ALTER TABLE ONLY public.asset_likes ADD CONSTRAINT asset_likes_pkey PRIMARY KEY (id);
CREATE UNIQUE INDEX uk_asset_likes_user_asset ON public.asset_likes USING btree (user_id, asset_id);
CREATE INDEX idx_asset_likes_asset ON public.asset_likes USING btree (asset_id);
CREATE INDEX idx_asset_likes_user_star ON public.asset_likes USING btree (user_id, star_id);
ALTER TABLE ONLY public.asset_likes ADD CONSTRAINT fk_asset_likes_asset FOREIGN KEY (asset_id) REFERENCES public.assets(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.asset_likes ADD CONSTRAINT fk_asset_likes_star FOREIGN KEY (star_id) REFERENCES public.stars(star_id) ON DELETE CASCADE;
ALTER TABLE ONLY public.asset_likes ADD CONSTRAINT fk_asset_likes_user FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
-- 铸造订单表
CREATE TABLE public.mint_orders (
order_id character varying(100) NOT NULL,
user_id bigint NOT NULL,
asset_id bigint,
star_id bigint NOT NULL,
status character varying(20) DEFAULT 'PENDING'::character varying NOT NULL,
cost_crystal bigint DEFAULT 0,
error_message text,
retry_count integer DEFAULT 0,
material_url character varying(500),
name character varying(100),
description text,
material_type character varying(50),
event character varying(100),
created_at bigint NOT NULL,
updated_at bigint NOT NULL,
minted_at bigint,
info text
);
ALTER TABLE ONLY public.mint_orders ADD CONSTRAINT mint_orders_pkey PRIMARY KEY (order_id);
CREATE INDEX idx_mint_orders_asset ON public.mint_orders USING btree (asset_id);
CREATE INDEX idx_mint_orders_created_at ON public.mint_orders USING btree (created_at DESC);
CREATE INDEX idx_mint_orders_status ON public.mint_orders USING btree (status);
CREATE INDEX idx_mint_orders_user_star ON public.mint_orders USING btree (user_id, star_id);
ALTER TABLE ONLY public.mint_orders ADD CONSTRAINT fk_mint_orders_asset FOREIGN KEY (asset_id) REFERENCES public.assets(id) ON DELETE SET NULL;
ALTER TABLE ONLY public.mint_orders ADD CONSTRAINT fk_mint_orders_star FOREIGN KEY (star_id) REFERENCES public.stars(star_id) ON DELETE CASCADE;
ALTER TABLE ONLY public.mint_orders ADD CONSTRAINT fk_mint_orders_user FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
-- =====================================================
-- 展馆相关表
-- =====================================================
-- 展位表
CREATE TABLE public.booth_slots (
slot_id bigint NOT NULL,
host_profile_id bigint NOT NULL,
user_id bigint NOT NULL,
star_id bigint NOT NULL,
slot_index bigint NOT NULL,
visibility character varying(20) DEFAULT 'public'::character varying,
is_enabled boolean DEFAULT false,
unlock_type character varying(20),
unlock_value bigint,
created_at bigint NOT NULL,
updated_at bigint NOT NULL
);
CREATE SEQUENCE public.booth_slots_slot_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
ALTER TABLE ONLY public.booth_slots ALTER COLUMN slot_id SET DEFAULT nextval('public.booth_slots_slot_id_seq'::regclass);
ALTER TABLE ONLY public.booth_slots ADD CONSTRAINT booth_slots_pkey PRIMARY KEY (slot_id);
CREATE UNIQUE INDEX idx_host_slot ON public.booth_slots USING btree (host_profile_id, slot_index);
CREATE INDEX idx_star_enabled ON public.booth_slots USING btree (star_id);
CREATE INDEX idx_user_star ON public.booth_slots USING btree (user_id, star_id);
ALTER TABLE ONLY public.booth_slots ADD CONSTRAINT fk_booth_slots_profile FOREIGN KEY (host_profile_id) REFERENCES public.fan_profiles(id) ON DELETE CASCADE;
-- 展品展示表
CREATE TABLE public.exhibitions (
id bigint NOT NULL,
asset_id bigint NOT NULL,
slot_id bigint NOT NULL,
host_profile_id bigint NOT NULL,
occupier_uid bigint NOT NULL,
occupier_star_id bigint NOT NULL,
start_time bigint NOT NULL,
expire_at bigint NOT NULL,
created_at bigint NOT NULL,
updated_at bigint NOT NULL,
deleted_at bigint
);
CREATE SEQUENCE public.exhibitions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
ALTER TABLE ONLY public.exhibitions ALTER COLUMN id SET DEFAULT nextval('public.exhibitions_id_seq'::regclass);
ALTER TABLE ONLY public.exhibitions ADD CONSTRAINT exhibitions_pkey PRIMARY KEY (id);
CREATE UNIQUE INDEX uk_asset ON public.exhibitions USING btree (asset_id);
CREATE INDEX idx_expire ON public.exhibitions USING btree (expire_at);
CREATE INDEX idx_host ON public.exhibitions USING btree (host_profile_id);
CREATE INDEX idx_occupier ON public.exhibitions USING btree (occupier_uid, occupier_star_id);
CREATE INDEX idx_slot ON public.exhibitions USING btree (slot_id);
ALTER TABLE ONLY public.exhibitions ADD CONSTRAINT fk_exhibitions_asset FOREIGN KEY (asset_id) REFERENCES public.assets(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.exhibitions ADD CONSTRAINT fk_exhibitions_slot FOREIGN KEY (slot_id) REFERENCES public.booth_slots(slot_id) ON DELETE CASCADE;
-- 展览收入记录表
CREATE TABLE public.exhibition_revenue_records (
id bigint NOT NULL,
user_id bigint NOT NULL,
star_id bigint NOT NULL,
exhibition_id bigint NOT NULL,
asset_id bigint NOT NULL,
slot_id bigint NOT NULL,
slot_owner_uid bigint NOT NULL,
slot_type character varying(20) NOT NULL,
crystal_amount bigint NOT NULL,
cycle_start_time bigint NOT NULL,
cycle_end_time bigint NOT NULL,
status character varying(20) DEFAULT 'claimable'::character varying NOT NULL,
claimed_at bigint,
created_at bigint NOT NULL
);
CREATE SEQUENCE public.exhibition_revenue_records_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
ALTER TABLE ONLY public.exhibition_revenue_records ALTER COLUMN id SET DEFAULT nextval('public.exhibition_revenue_records_id_seq'::regclass);
ALTER TABLE ONLY public.exhibition_revenue_records ADD CONSTRAINT exhibition_revenue_records_pkey PRIMARY KEY (id);
CREATE INDEX idx_user_revenue ON public.exhibition_revenue_records USING btree (user_id, star_id);
-- =====================================================
-- 社交相关表
-- =====================================================
-- 好友请求表
CREATE TABLE public.friend_requests (
id bigint NOT NULL,
from_user_id bigint NOT NULL,
to_user_id bigint NOT NULL,
star_id bigint NOT NULL,
message character varying(200),
status character varying(20) DEFAULT 'pending'::character varying NOT NULL,
created_at bigint NOT NULL,
updated_at bigint NOT NULL,
expires_at bigint,
processed_at bigint
);
CREATE SEQUENCE public.friend_requests_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
ALTER TABLE ONLY public.friend_requests ALTER COLUMN id SET DEFAULT nextval('public.friend_requests_id_seq'::regclass);
ALTER TABLE ONLY public.friend_requests ADD CONSTRAINT friend_requests_pkey PRIMARY KEY (id);
CREATE INDEX idx_friend_requests_expires ON public.friend_requests USING btree (expires_at);
CREATE INDEX idx_friend_requests_from_status ON public.friend_requests USING btree (from_user_id, status, created_at DESC);
CREATE INDEX idx_friend_requests_star ON public.friend_requests USING btree (star_id);
CREATE INDEX idx_friend_requests_to_status ON public.friend_requests USING btree (to_user_id, status, created_at DESC);
CREATE INDEX idx_friend_requests_users_star ON public.friend_requests USING btree (from_user_id, to_user_id, star_id, created_at DESC);
ALTER TABLE ONLY public.friend_requests ADD CONSTRAINT fk_friend_requests_from_user FOREIGN KEY (from_user_id) REFERENCES public.users(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.friend_requests ADD CONSTRAINT fk_friend_requests_to_user FOREIGN KEY (to_user_id) REFERENCES public.users(id) ON DELETE CASCADE;
-- 好友关系表
CREATE TABLE public.friendships (
id bigint NOT NULL,
user_id bigint NOT NULL,
friend_id bigint NOT NULL,
star_id bigint NOT NULL,
status character varying(20) DEFAULT 'accepted'::character varying NOT NULL,
remark character varying(50),
intimacy integer DEFAULT 0 NOT NULL,
created_at bigint NOT NULL,
updated_at bigint NOT NULL
);
CREATE SEQUENCE public.friendships_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
ALTER TABLE ONLY public.friendships ALTER COLUMN id SET DEFAULT nextval('public.friendships_id_seq'::regclass);
ALTER TABLE ONLY public.friendships ADD CONSTRAINT friendships_pkey PRIMARY KEY (id);
CREATE UNIQUE INDEX uk_friendships_user_friend_star ON public.friendships USING btree (user_id, friend_id, star_id);
CREATE INDEX idx_friendships_friend_star ON public.friendships USING btree (friend_id);
CREATE INDEX idx_friendships_list_query ON public.friendships USING btree (user_id, friend_id, star_id, status, remark, created_at);
CREATE INDEX idx_friendships_user_star_created ON public.friendships USING btree (user_id, star_id, created_at DESC);
CREATE INDEX idx_friendships_user_star_status ON public.friendships USING btree (user_id, star_id, status);
ALTER TABLE ONLY public.friendships ADD CONSTRAINT fk_friendships_friend FOREIGN KEY (friend_id) REFERENCES public.users(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.friendships ADD CONSTRAINT fk_friendships_user FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
-- =====================================================
-- 任务相关表
-- =====================================================
-- 任务定义表
CREATE TABLE public.task_definitions (
id bigint NOT NULL,
task_key character varying(50) NOT NULL,
task_type character varying(20) NOT NULL,
name character varying(100) NOT NULL,
description text,
crystal_reward bigint DEFAULT 0 NOT NULL,
exp_reward bigint DEFAULT 0 NOT NULL,
sort_order integer DEFAULT 0 NOT NULL,
is_active boolean DEFAULT true NOT NULL,
created_at bigint NOT NULL,
updated_at bigint NOT NULL
);
CREATE SEQUENCE public.task_definitions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
ALTER TABLE ONLY public.task_definitions ALTER COLUMN id SET DEFAULT nextval('public.task_definitions_id_seq'::regclass);
ALTER TABLE ONLY public.task_definitions ADD CONSTRAINT task_definitions_pkey PRIMARY KEY (id);
CREATE UNIQUE INDEX idx_task_definitions_task_key ON public.task_definitions USING btree (task_key);
-- 用户任务进度表
CREATE TABLE public.user_task_progress (
id bigint NOT NULL,
user_id bigint NOT NULL,
star_id bigint NOT NULL,
task_key character varying(50) NOT NULL,
status character varying(20) DEFAULT 'pending'::character varying NOT NULL,
completed_at bigint,
claimed_at bigint,
created_at bigint NOT NULL,
updated_at bigint NOT NULL
);
CREATE SEQUENCE public.user_task_progress_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
ALTER TABLE ONLY public.user_task_progress ALTER COLUMN id SET DEFAULT nextval('public.user_task_progress_id_seq'::regclass);
ALTER TABLE ONLY public.user_task_progress ADD CONSTRAINT user_task_progress_pkey PRIMARY KEY (id);
CREATE UNIQUE INDEX uk_user_task ON public.user_task_progress USING btree (user_id, star_id, task_key);
-- 用户引导状态表
CREATE TABLE public.user_onboarding_status (
id bigint NOT NULL,
user_id bigint NOT NULL,
star_id bigint NOT NULL,
is_onboarding_completed boolean DEFAULT false NOT NULL,
is_onboarding_claimed boolean DEFAULT false NOT NULL,
has_friend_display_bonus boolean DEFAULT false NOT NULL,
onboarding_completed_at bigint,
onboarding_claimed_at bigint,
created_at bigint NOT NULL,
updated_at bigint NOT NULL
);
CREATE SEQUENCE public.user_onboarding_status_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
ALTER TABLE ONLY public.user_onboarding_status ALTER COLUMN id SET DEFAULT nextval('public.user_onboarding_status_id_seq'::regclass);
ALTER TABLE ONLY public.user_onboarding_status ADD CONSTRAINT user_onboarding_status_pkey PRIMARY KEY (id);
CREATE UNIQUE INDEX uk_user_star_onboarding ON public.user_onboarding_status USING btree (user_id, star_id);
-- =====================================================
-- 活动相关表
-- =====================================================
-- 活动表
CREATE TABLE public.activities (
id bigint NOT NULL,
activity_type character varying(50) NOT NULL,
title character varying(100) NOT NULL,
description text,
star_id bigint NOT NULL,
start_time bigint NOT NULL,
end_time bigint NOT NULL,
target_progress bigint DEFAULT 1000 NOT NULL,
current_progress bigint DEFAULT 0 NOT NULL,
status character varying(20) DEFAULT 'pending'::character varying,
stage_configs jsonb,
created_at bigint NOT NULL,
updated_at bigint NOT NULL,
theme character varying(100),
overall_end_time bigint DEFAULT 0
);
CREATE SEQUENCE public.activities_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
ALTER TABLE ONLY public.activities ALTER COLUMN id SET DEFAULT nextval('public.activities_id_seq'::regclass);
ALTER TABLE ONLY public.activities ADD CONSTRAINT activities_pkey PRIMARY KEY (id);
CREATE INDEX idx_activities_star_id ON public.activities USING btree (star_id);
CREATE INDEX idx_activities_start_end ON public.activities USING btree (start_time, end_time);
CREATE INDEX idx_activities_status ON public.activities USING btree (status);
-- 活动道具表
CREATE TABLE public.activity_items (
id bigint NOT NULL,
activity_id bigint NOT NULL,
item_type character varying(50) NOT NULL,
item_name character varying(50) NOT NULL,
icon_url character varying(500),
crystal_cost bigint NOT NULL,
contribution_points bigint NOT NULL,
sort_order integer DEFAULT 0 NOT NULL,
is_active boolean DEFAULT true NOT NULL,
created_at bigint NOT NULL,
updated_at bigint NOT NULL
);
CREATE SEQUENCE public.activity_items_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
ALTER TABLE ONLY public.activity_items ALTER COLUMN id SET DEFAULT nextval('public.activity_items_id_seq'::regclass);
ALTER TABLE ONLY public.activity_items ADD CONSTRAINT activity_items_pkey PRIMARY KEY (id);
CREATE INDEX idx_activity_items_activity ON public.activity_items USING btree (activity_id);
CREATE INDEX idx_activity_items_type ON public.activity_items USING btree (item_type);
ALTER TABLE ONLY public.activity_items ADD CONSTRAINT fk_activity_items_activity FOREIGN KEY (activity_id) REFERENCES public.activities(id) ON DELETE CASCADE;
-- 活动贡献记录表
CREATE TABLE public.activity_contributions (
id bigint NOT NULL,
activity_id bigint NOT NULL,
user_id bigint NOT NULL,
star_id bigint NOT NULL,
item_id bigint NOT NULL,
item_type character varying(50) NOT NULL,
quantity integer DEFAULT 1 NOT NULL,
crystal_spent bigint NOT NULL,
contribution_points bigint NOT NULL,
created_at bigint NOT NULL
);
CREATE SEQUENCE public.activity_contributions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
ALTER TABLE ONLY public.activity_contributions ALTER COLUMN id SET DEFAULT nextval('public.activity_contributions_id_seq'::regclass);
ALTER TABLE ONLY public.activity_contributions ADD CONSTRAINT activity_contributions_pkey PRIMARY KEY (id);
CREATE INDEX idx_activity_contributions_activity ON public.activity_contributions USING btree (activity_id);
CREATE INDEX idx_activity_contributions_created ON public.activity_contributions USING btree (created_at DESC);
CREATE INDEX idx_activity_contributions_user_star ON public.activity_contributions USING btree (user_id, star_id);
ALTER TABLE ONLY public.activity_contributions ADD CONSTRAINT fk_activity_contributions_activity FOREIGN KEY (activity_id) REFERENCES public.activities(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.activity_contributions ADD CONSTRAINT fk_activity_contributions_item FOREIGN KEY (item_id) REFERENCES public.activity_items(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.activity_contributions ADD CONSTRAINT fk_activity_contributions_star FOREIGN KEY (star_id) REFERENCES public.stars(star_id) ON DELETE CASCADE;
ALTER TABLE ONLY public.activity_contributions ADD CONSTRAINT fk_activity_contributions_user FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
-- 用户活动统计表
CREATE TABLE public.activity_user_stats (
id bigint NOT NULL,
activity_id bigint NOT NULL,
user_id bigint NOT NULL,
star_id bigint NOT NULL,
total_contribution bigint DEFAULT 0 NOT NULL,
total_crystal_spent bigint DEFAULT 0 NOT NULL,
total_items integer DEFAULT 0 NOT NULL,
last_contribute_at bigint NOT NULL,
created_at bigint NOT NULL,
updated_at bigint NOT NULL
);
CREATE SEQUENCE public.activity_user_stats_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
ALTER TABLE ONLY public.activity_user_stats ALTER COLUMN id SET DEFAULT nextval('public.activity_user_stats_id_seq'::regclass);
ALTER TABLE ONLY public.activity_user_stats ADD CONSTRAINT activity_user_stats_pkey PRIMARY KEY (id);
CREATE UNIQUE INDEX uk_activity_user_star ON public.activity_user_stats UNIQUE (activity_id, user_id, star_id);
CREATE INDEX idx_activity_user_stats_activity ON public.activity_user_stats USING btree (activity_id);
CREATE INDEX idx_activity_user_stats_contribution ON public.activity_user_stats USING btree (activity_id, total_contribution DESC);
CREATE INDEX idx_activity_user_stats_user_star ON public.activity_user_stats USING btree (user_id, star_id);
ALTER TABLE ONLY public.activity_user_stats ADD CONSTRAINT fk_activity_user_stats_activity FOREIGN KEY (activity_id) REFERENCES public.activities(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.activity_user_stats ADD CONSTRAINT fk_activity_user_stats_star FOREIGN KEY (star_id) REFERENCES public.stars(star_id) ON DELETE CASCADE;
ALTER TABLE ONLY public.activity_user_stats ADD CONSTRAINT fk_activity_user_stats_user FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;

View File

@ -1,4 +0,0 @@
-- V2__add_deleted_at_to_exhibitions.sql
-- 为 exhibitions 表添加 deleted_at 字段(软删除)
ALTER TABLE public.exhibitions ADD COLUMN IF NOT EXISTS deleted_at bigint;

View File

@ -1,17 +0,0 @@
-- V3__seed_data.sql
-- 种子数据(测试用)
-- 插入测试明星
INSERT INTO public.stars (star_id, name, tag, identity_id, is_active, created_at, updated_at) VALUES
(87, '测试明星', '测试', 'test_star_001', true, 1704067200000, 1704067200000)
ON CONFLICT DO NOTHING;
-- 插入测试用户
INSERT INTO public.users (id, mobile, password_hash, is_active, created_at, updated_at) VALUES
(1, '13800138000', '$2a$10$N9qo8uLOickgx2ZMRZoMye6e7q5R5pR6Vx9qPCr5dLq5R5pR6Vx9q', true, 1704067200000, 1704067200000)
ON CONFLICT DO NOTHING;
-- 插入测试粉丝档案
INSERT INTO public.fan_profiles (id, user_id, star_id, nickname, level, times, social, experience, coin_balance, crystal_balance, starbook_limit, slot_limit, assets_count, is_active, created_at, updated_at, avatar_url) VALUES
(1, 1, 87, '测试用户', 5, 3, 10, 1000, 500, 100, 3, 3, 5, true, 1704067200000, 1704067200000, 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/avatar/1/87/avatar.png')
ON CONFLICT DO NOTHING;

View File

@ -1,53 +0,0 @@
-- V4__seed_data.sql
-- 种子数据
-- 插入明星数据
INSERT INTO public.stars (star_id, name, tag, name_en, pic_url, description, identity_id, is_active, created_at, updated_at) VALUES
(87, '肖战', '小飞侠', 'Xiao Zhan', NULL, NULL, 'xz', true, 1773322573872, 1773322573872),
(88, '王一博', '小摩托', 'Wang Yibo', NULL, NULL, 'wyb', true, 1773322573872, 1773322573872),
(89, '杨洋', NULL, 'Yang Yang', NULL, NULL, 'yy', true, 1773322573872, 1773322573872),
(93, 'Lisa', 'BLACKPINK', 'Lalisa Manoban', 'https://example.com/lisa.jpg', 'BLACKPINK成员', 'lisa_test_001', true, 1773407317000, 1773407317000),
(94, 'Jennie', 'BLACKPINK', 'Jennie Kim', 'https://example.com/jennie.jpg', 'BLACKPINK成员', 'jennie_test_001', true, 1773407317000, 1773407317000),
(95, 'Rosé', 'BLACKPINK', 'Park Chae-young', 'https://example.com/rose.jpg', 'BLACKPINK成员', 'rose_test_001', true, 1773407317000, 1773407317000)
ON CONFLICT (star_id) DO UPDATE SET name = EXCLUDED.name, tag = EXCLUDED.tag;
-- 插入用户数据
INSERT INTO public.users (id, mobile, password_hash, access_token, token_expires_at, avatar_url, global_wallet_address, is_active, created_at, updated_at, deleted_at) VALUES
(1, '13900000001', '$2a$10$bNqpiVCSSrhxAsUelgkEp.j1untPPWMDT5208fmcUPKpsFHZlhjrW', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoxLCJzdGFyX2lkIjo4NywidXBkYXRlZF9hdCI6MTc3MzU4MTI5MiwiZXhwIjoxNzc3NTI5OTg5LCJpYXQiOjE3NzY5MjUxODl9.LooVCY-ST2y02qKud8A6GRVL1RxOy4pXVD6KC7NLs6w', 1777529989817, 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/avatar/1/87/avatar.png', NULL, true, 1773322609887, 1773581292, NULL),
(2, '17319409126', '$2a$10$bNqpiVCSSrhxAsUelgkEp.j1untPPWMDT5208fmcUPKpsFHZlhjrW', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoyLCJzdGFyX2lkIjo4NywidXBkYXRlZF9hdCI6MTc3MzMyNDEwMTU5OCwiZXhwIjoxNzc0NDIxOTIxLCJpYXQiOjE3NzM4MTcxMjF9.GnAL9exh-VcXDHqwTn1bNKVAEAg6xfMMpd6JTqkwugk', 1774421921871, NULL, NULL, true, 1773324101598, 1773324101598, NULL),
(8, '13800000001', '$2a$10$LC8XORj6Nx9nT6j5QHfN5u2nB4z8e0v2dWm7X2uF5m6W6br8NnDPS', NULL, NULL, NULL, NULL, true, 1773407317000, 1776649807972, NULL),
(9, '13800000002', '$2a$10$xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', NULL, NULL, NULL, NULL, true, 1773407317000, 1773407317000, NULL),
(10, '13800000003', '$2a$10$xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', NULL, NULL, NULL, NULL, true, 1773407317000, 1773407317000, NULL),
(11, '13800000004', '$2a$10$xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', NULL, NULL, NULL, NULL, true, 1773407317000, 1773407317000, NULL),
(12, '13800000005', '$2a$10$xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', NULL, NULL, NULL, NULL, true, 1773407317000, 1773407317000, NULL)
ON CONFLICT (id) DO UPDATE SET access_token = EXCLUDED.access_token, updated_at = EXCLUDED.updated_at;
-- 插入粉丝档案数据
INSERT INTO public.fan_profiles (id, user_id, star_id, nickname, level, times, social, experience, coin_balance, crystal_balance, tags, starbook_limit, slot_limit, assets_count, chain_address, is_active, created_at, updated_at, avatar_url) VALUES
(1, 1, 87, '测试用户', 6, 1, 0, 1750, 0, 10919, '[]', 3, 3, 42, NULL, true, 1773322609890, 1776926969, 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/avatar/1/87/avatar.png'),
(2, 2, 87, 'topfans1', 1, 1, 0, 0, 0, 0, '[]', 3, 3, 0, NULL, true, 1773324101600, 1773324101600, NULL)
ON CONFLICT (id) DO UPDATE SET level = EXCLUDED.level, experience = EXCLUDED.experience, updated_at = EXCLUDED.updated_at;
-- 插入 Booth Slots 数据
INSERT INTO public.booth_slots (slot_id, host_profile_id, user_id, star_id, slot_index, visibility, is_enabled, unlock_type, unlock_value, created_at, updated_at) VALUES
(37, 1, 1, 87, 1, 'public', true, 'free', 0, 1773748940460, 1773748940460),
(38, 1, 1, 87, 2, 'public', true, 'free', 0, 1773748940460, 1773748940460),
(39, 1, 1, 87, 3, 'public', true, 'free', 0, 1773748940460, 1773748940460),
(40, 1, 1, 87, 4, 'private', true, 'free', 0, 1773748940460, 1773748940460),
(41, 1, 1, 87, 5, 'private', true, 'free', 0, 1773748940460, 1773748940460),
(42, 1, 1, 87, 6, 'private', true, 'free', 0, 1773748940460, 1773748940460)
ON CONFLICT (slot_id) DO NOTHING;
-- 插入 Assets 数据
INSERT INTO public.assets (id, owner_uid, star_id, name, cover_url, material_url, description, grade, tags, visibility, status, tx_hash, block_number, like_count, is_original, created_at, updated_at, minted_at, deleted_at, is_active, info) VALUES
(17, 1, 87, '1', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/covers/17_1775472017.png', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/ai_generated_1775472013603_g87iwk.png', NULL, NULL, NULL, 'private', 1, '0x1922ffb92fcd1a7e4a8c6b3347e8e0791f6107fa44cbde1734ecb1bcd861d63c', 1493537, 4, false, 1775472014756, 1775472018619, 1775472018619, NULL, true, NULL),
(18, 1, 87, '1', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/covers/18_1775539093.png', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/ai_generated_1775539090338_fwzxhs.png', NULL, NULL, NULL, 'private', 1, '0x40ca6efcf29f47731453f01b5c364cde52acbce597c1fbf8261301cc44ec4b7a', 1406147, 2, false, 1775539090589, 1775539093945, 1775539093945, NULL, true, NULL),
(19, 1, 87, '未命名藏品', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/covers/19_1775812743.png', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/ai_generated_1775812740051_gf8ew2.png', NULL, NULL, NULL, 'private', 1, '0x0e3e47c58814e52465ac1e928f3392ff1c692ea448103fcb03c4a10077141308', 1219083, 3, false, 1775812740261, 1775812743690, 1775812743690, NULL, true, '111'),
(20, 1, 87, '星卡', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/covers/20_1775812994.png', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/1775812991404.jpg', NULL, NULL, NULL, 'private', 1, '0x49d04d7463cf03374f6e622d739f69e83cd4ba84b145627f039a22340daead93', 1938046, 2, false, 1775812991507, 1775812994841, 1775812994841, NULL, true, '11'),
(21, 1, 87, '星卡', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/covers/21_1775813155.png', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/1775813152104.jpg', NULL, NULL, NULL, 'private', 1, '0x6d7c0c276d7485d17e6dea4c9d1e394315613d69114699d341c221a22e8156f8', 1118388, 2, false, 1775813152198, 1775813155515, 1775813155515, NULL, true, '2')
ON CONFLICT (id) DO UPDATE SET like_count = EXCLUDED.like_count;
-- 插入 Exhibitions 数据
INSERT INTO public.exhibitions (id, asset_id, slot_id, host_profile_id, occupier_uid, occupier_star_id, start_time, expire_at, created_at, updated_at, deleted_at) VALUES
(1, 17, 37, 1, 1, 87, 1776926400000, 1777555200000, 1776926400000, 1776926400000, NULL)
ON CONFLICT (id) DO NOTHING;

View File

@ -1,53 +0,0 @@
-- 铸造经济:按「第几次铸爱」阶梯扣水晶(见 docs/specs/2026-04-15-economic-system-design.md
-- 未建表/未插数时,资产服务查配置会得到 record not found网关表现为 code 17。
-- 用户在某 star 下的累计铸爱次数CreateMintOrder 会读/写)
CREATE TABLE IF NOT EXISTS public.user_mint_count (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL,
star_id BIGINT NOT NULL,
mint_count INT NOT NULL DEFAULT 0,
revenue_boost_bps INT NOT NULL DEFAULT 0,
updated_at BIGINT NOT NULL,
CONSTRAINT uk_user_mint_count_user_star UNIQUE (user_id, star_id)
);
CREATE INDEX IF NOT EXISTS idx_user_mint_count_user ON public.user_mint_count USING btree (user_id);
CREATE INDEX IF NOT EXISTS idx_user_mint_count_star ON public.user_mint_count USING btree (star_id);
COMMENT ON TABLE public.user_mint_count IS '用户在某偶像下的累计铸爱次数与收益加成(基点)';
-- 第 N 次铸爱对应扣费与保底概率mint_count 唯一)
CREATE TABLE IF NOT EXISTS public.mint_cost_config (
id BIGSERIAL PRIMARY KEY,
mint_count INT NOT NULL,
cost_crystal BIGINT NOT NULL,
probability BIGINT NOT NULL DEFAULT 0,
reward_type VARCHAR(50) DEFAULT NULL,
reward_value BIGINT NOT NULL DEFAULT 0,
description VARCHAR(255),
updated_at BIGINT NOT NULL,
CONSTRAINT uk_mint_cost_config_mint_count UNIQUE (mint_count)
);
COMMENT ON TABLE public.mint_cost_config IS '铸爱次数阶梯消耗与保底配置';
INSERT INTO public.mint_cost_config (mint_count, cost_crystal, probability, reward_type, reward_value, description, updated_at)
VALUES
(1, 2, 0, NULL, 0, '第1次', 1773322573872),
(2, 4, 0, NULL, 0, '第2次', 1773322573872),
(3, 8, 0, NULL, 0, '第3次', 1773322573872),
(4, 16, 0, NULL, 0, '第4次', 1773322573872),
(5, 32, 0, NULL, 0, '第5次', 1773322573872),
(6, 64, 0, NULL, 0, '第6次', 1773322573872),
(7, 128, 0, NULL, 0, '第7次', 1773322573872),
(8, 256, 0, NULL, 0, '第8次', 1773322573872),
(9, 512, 20, '收益提升', 5, '小保底', 1773322573872),
(10, 1024, 100, '收益提升', 5, '大保底', 1773322573872)
ON CONFLICT (mint_count) DO UPDATE SET
cost_crystal = EXCLUDED.cost_crystal,
probability = EXCLUDED.probability,
reward_type = EXCLUDED.reward_type,
reward_value = EXCLUDED.reward_value,
description = EXCLUDED.description,
updated_at = EXCLUDED.updated_at;

View File

@ -1,352 +0,0 @@
-- V6__consolidated_migrations.sql
-- 整合所有分散的迁移脚本2026-05-15
-- 包含: materials, asset_material_relations, 经济系统表, 字段修改等
-- =====================================================
-- Part 1: materials 素材主表
-- =====================================================
CREATE TABLE IF NOT EXISTS public.materials (
id BIGSERIAL PRIMARY KEY,
oss_key VARCHAR(255) NOT NULL,
original_name VARCHAR(255) NOT NULL,
file_size BIGINT NOT NULL,
mime_type VARCHAR(100) NOT NULL,
width INT,
height INT,
hash VARCHAR(64) NOT NULL,
created_by BIGINT NOT NULL,
star_id BIGINT NOT NULL DEFAULT 0,
created_at BIGINT NOT NULL,
updated_at BIGINT NOT NULL,
deleted_at BIGINT
);
CREATE UNIQUE INDEX IF NOT EXISTS uk_materials_oss_key ON public.materials(oss_key);
CREATE INDEX IF NOT EXISTS idx_materials_hash ON public.materials(hash);
CREATE INDEX IF NOT EXISTS idx_materials_created_by ON public.materials(created_by);
CREATE INDEX IF NOT EXISTS idx_materials_star_id ON public.materials(star_id);
COMMENT ON TABLE public.materials IS '素材主表';
-- =====================================================
-- Part 2: asset_material_relations 资产-素材关联表
-- =====================================================
CREATE TABLE IF NOT EXISTS public.asset_material_relations (
id BIGSERIAL PRIMARY KEY,
asset_id BIGINT NOT NULL,
material_id BIGINT NOT NULL,
material_type VARCHAR(50) NOT NULL,
layer_order INT NOT NULL DEFAULT 0,
pos_x DOUBLE PRECISION,
pos_y DOUBLE PRECISION,
opacity DOUBLE PRECISION DEFAULT 1.0,
rotation DOUBLE PRECISION DEFAULT 0,
scale_x DOUBLE PRECISION DEFAULT 1.0,
scale_y DOUBLE PRECISION DEFAULT 1.0,
version INT NOT NULL DEFAULT 1,
created_at BIGINT NOT NULL,
updated_at BIGINT NOT NULL,
deleted_at BIGINT
);
CREATE INDEX IF NOT EXISTS idx_amr_asset_id ON public.asset_material_relations(asset_id) WHERE deleted_at IS NULL;
CREATE INDEX IF NOT EXISTS idx_amr_material_id ON public.asset_material_relations(material_id) WHERE deleted_at IS NULL;
CREATE INDEX IF NOT EXISTS idx_amr_asset_type_layer ON public.asset_material_relations(asset_id, material_type, layer_order) WHERE deleted_at IS NULL;
CREATE UNIQUE INDEX IF NOT EXISTS uk_amr_asset_type_active ON public.asset_material_relations(asset_id, material_type) WHERE deleted_at IS NULL;
CREATE UNIQUE INDEX IF NOT EXISTS uk_amr_asset_layer_active ON public.asset_material_relations(asset_id, layer_order) WHERE deleted_at IS NULL;
COMMENT ON TABLE public.asset_material_relations IS '资产-素材关联表';
-- 外键约束(如果 assets 表已存在)
DO $$
BEGIN
IF EXISTS (SELECT 1 FROM pg_tables WHERE tablename = 'assets') THEN
ALTER TABLE public.asset_material_relations
ADD CONSTRAINT fk_amr_asset
FOREIGN KEY (asset_id) REFERENCES public.assets(id) ON DELETE CASCADE;
END IF;
EXCEPTION WHEN others THEN
RAISE NOTICE 'Foreign key constraint for asset_material_relations skipped: %', SQLERRM;
END $$;
DO $$
BEGIN
IF EXISTS (SELECT 1 FROM pg_tables WHERE tablename = 'materials') THEN
ALTER TABLE public.asset_material_relations
ADD CONSTRAINT fk_amr_material
FOREIGN KEY (material_id) REFERENCES public.materials(id) ON DELETE RESTRICT;
END IF;
EXCEPTION WHEN others THEN
RAISE NOTICE 'Foreign key constraint for asset_material_relations skipped: %', SQLERRM;
END $$;
-- =====================================================
-- Part 3: user_mint_count 铸爱次数表
-- =====================================================
CREATE TABLE IF NOT EXISTS public.user_mint_count (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL,
star_id BIGINT NOT NULL,
mint_count INT NOT NULL DEFAULT 0,
revenue_boost_bps INT NOT NULL DEFAULT 0,
updated_at BIGINT NOT NULL,
CONSTRAINT uk_user_mint_count_user_star UNIQUE (user_id, star_id)
);
CREATE INDEX IF NOT EXISTS idx_user_mint_count_user ON public.user_mint_count USING btree (user_id);
CREATE INDEX IF NOT EXISTS idx_user_mint_count_star ON public.user_mint_count USING btree (star_id);
COMMENT ON TABLE public.user_mint_count IS '用户在某偶像下的累计铸爱次数与收益加成(基点)';
-- =====================================================
-- Part 4: mint_cost_config 铸爱阶梯配置表
-- =====================================================
CREATE TABLE IF NOT EXISTS public.mint_cost_config (
id BIGSERIAL PRIMARY KEY,
mint_count INT NOT NULL,
cost_crystal BIGINT NOT NULL,
probability BIGINT NOT NULL DEFAULT 0,
reward_type VARCHAR(50) DEFAULT NULL,
reward_value BIGINT NOT NULL DEFAULT 0,
description VARCHAR(255),
updated_at BIGINT NOT NULL,
CONSTRAINT uk_mint_cost_config_mint_count UNIQUE (mint_count)
);
COMMENT ON TABLE public.mint_cost_config IS '铸爱次数阶梯消耗与保底配置';
-- 插入铸爱阶梯数据
INSERT INTO public.mint_cost_config (mint_count, cost_crystal, probability, reward_type, reward_value, description, updated_at)
VALUES
(1, 2, 0, NULL, 0, '第1次', 1773322573872),
(2, 4, 0, NULL, 0, '第2次', 1773322573872),
(3, 8, 0, NULL, 0, '第3次', 1773322573872),
(4, 16, 0, NULL, 0, '第4次', 1773322573872),
(5, 32, 0, NULL, 0, '第5次', 1773322573872),
(6, 64, 0, NULL, 0, '第6次', 1773322573872),
(7, 128, 0, NULL, 0, '第7次', 1773322573872),
(8, 256, 0, NULL, 0, '第8次', 1773322573872),
(9, 512, 20, '收益提升', 5, '小保底', 1773322573872),
(10, 1024, 100, '收益提升', 5, '大保底', 1773322573872)
ON CONFLICT (mint_count) DO UPDATE SET
cost_crystal = EXCLUDED.cost_crystal,
probability = EXCLUDED.probability,
reward_type = EXCLUDED.reward_type,
reward_value = EXCLUDED.reward_value,
description = EXCLUDED.description,
updated_at = EXCLUDED.updated_at;
-- =====================================================
-- Part 5: 字段修改迁移
-- =====================================================
-- 5.1 exhibitions 表添加 deleted_at 字段
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name = 'exhibitions' AND column_name = 'deleted_at'
) THEN
ALTER TABLE public.exhibitions ADD COLUMN deleted_at BIGINT;
RAISE NOTICE 'Column deleted_at added to exhibitions table';
ELSE
RAISE NOTICE 'Column deleted_at already exists in exhibitions table';
END IF;
END $$;
-- 5.2 assets 表添加 material_type 字段
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name = 'assets' AND column_name = 'material_type'
) THEN
ALTER TABLE public.assets ADD COLUMN material_type VARCHAR(50);
RAISE NOTICE 'Column material_type added to assets table';
ELSE
RAISE NOTICE 'Column material_type already exists in assets table';
END IF;
END $$;
-- 5.3 activities 表添加 icon 字段
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name = 'activities' AND column_name = 'icon'
) THEN
ALTER TABLE public.activities ADD COLUMN icon VARCHAR(500) DEFAULT '';
RAISE NOTICE 'Column icon added to activities table';
ELSE
RAISE NOTICE 'Column icon already exists in activities table';
END IF;
END $$;
-- 5.4 activities 表添加 overall_end_time 字段
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name = 'activities' AND column_name = 'overall_end_time'
) THEN
ALTER TABLE public.activities ADD COLUMN overall_end_time BIGINT DEFAULT 0;
RAISE NOTICE 'Column overall_end_time added to activities table';
ELSE
RAISE NOTICE 'Column overall_end_time already exists in activities table';
END IF;
END $$;
-- 5.5 fan_profiles 表添加 avatar_url 字段
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name = 'fan_profiles' AND column_name = 'avatar_url'
) THEN
ALTER TABLE public.fan_profiles ADD COLUMN avatar_url VARCHAR(500);
RAISE NOTICE 'Column avatar_url added to fan_profiles table';
ELSE
RAISE NOTICE 'Column avatar_url already exists in fan_profiles table';
END IF;
END $$;
-- 5.6 assets 表添加 is_original 字段
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name = 'assets' AND column_name = 'is_original'
) THEN
ALTER TABLE public.assets ADD COLUMN is_original BOOLEAN DEFAULT false;
RAISE NOTICE 'Column is_original added to assets table';
ELSE
RAISE NOTICE 'Column is_original already exists in assets table';
END IF;
END $$;
-- 5.7 activities 表添加 theme 字段
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name = 'activities' AND column_name = 'theme'
) THEN
ALTER TABLE public.activities ADD COLUMN theme VARCHAR(100);
RAISE NOTICE 'Column theme added to activities table';
ELSE
RAISE NOTICE 'Column theme already exists in activities table';
END IF;
END $$;
-- =====================================================
-- Part 6: 索引和约束修改
-- =====================================================
-- 6.1 asset_likes 表唯一约束修改(添加 star_id
DO $$
BEGIN
IF EXISTS (
SELECT 1 FROM pg_constraint WHERE conname = 'uk_asset_likes_user_asset'
) THEN
ALTER TABLE public.asset_likes DROP CONSTRAINT uk_asset_likes_user_asset;
RAISE NOTICE 'Old constraint uk_asset_likes_user_asset dropped';
END IF;
EXCEPTION WHEN others THEN
RAISE NOTICE 'Constraint uk_asset_likes_user_asset not found or already dropped: %', SQLERRM;
END $$;
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM pg_constraint WHERE conname = 'uk_asset_likes_user_asset_star'
) THEN
ALTER TABLE public.asset_likes ADD CONSTRAINT uk_asset_likes_user_asset_star UNIQUE (user_id, asset_id, star_id);
RAISE NOTICE 'New constraint uk_asset_likes_user_asset_star added';
END IF;
EXCEPTION WHEN others THEN
RAISE NOTICE 'Constraint uk_asset_likes_user_asset_star already exists: %', SQLERRM;
END $$;
-- 6.2 exhibitions 表唯一约束移除asset_id
DO $$
BEGIN
IF EXISTS (
SELECT 1 FROM pg_constraint WHERE conname = 'uk_asset'
) THEN
ALTER TABLE public.exhibitions DROP CONSTRAINT uk_asset;
RAISE NOTICE 'Constraint uk_asset dropped from exhibitions table';
END IF;
EXCEPTION WHEN others THEN
RAISE NOTICE 'Constraint uk_asset not found or already dropped: %', SQLERRM;
END $$;
-- 6.3 exhibitions 表添加 idx_asset 普通索引
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM pg_indexes WHERE indexname = 'idx_asset' AND schemaname = 'public'
) THEN
CREATE INDEX idx_asset ON public.exhibitions(asset_id);
RAISE NOTICE 'Index idx_asset created on exhibitions table';
END IF;
EXCEPTION WHEN others THEN
RAISE NOTICE 'Index idx_asset already exists: %', SQLERRM;
END $$;
-- =====================================================
-- Migration completed
-- =====================================================
DO $$
BEGIN
RAISE NOTICE 'V6__consolidated_migrations completed successfully';
END $$;
-- 素材主表
CREATE TABLE materials (
id BIGSERIAL PRIMARY KEY,
oss_key VARCHAR(255) NOT NULL,
original_name VARCHAR(255) NOT NULL,
file_size BIGINT NOT NULL,
mime_type VARCHAR(100) NOT NULL,
width INT,
height INT,
hash VARCHAR(64) NOT NULL,
created_by BIGINT NOT NULL,
star_id BIGINT NOT NULL DEFAULT 0,
created_at BIGINT NOT NULL,
updated_at BIGINT NOT NULL,
deleted_at BIGINT
);
CREATE UNIQUE INDEX uk_materials_oss_key ON materials(oss_key);
CREATE INDEX idx_materials_hash ON materials(hash);
CREATE INDEX idx_materials_created_by ON materials(created_by);
CREATE INDEX idx_materials_star_id ON materials(star_id);
-- 资产-素材关联表
CREATE TABLE asset_material_relations (
id BIGSERIAL PRIMARY KEY,
asset_id BIGINT NOT NULL REFERENCES assets(id) ON DELETE CASCADE,
material_id BIGINT NOT NULL REFERENCES materials(id) ON DELETE RESTRICT,
material_type VARCHAR(50) NOT NULL,
layer_order INT NOT NULL DEFAULT 0,
pos_x DOUBLE PRECISION,
pos_y DOUBLE PRECISION,
opacity DOUBLE PRECISION DEFAULT 1.0,
rotation DOUBLE PRECISION DEFAULT 0,
scale_x DOUBLE PRECISION DEFAULT 1.0,
scale_y DOUBLE PRECISION DEFAULT 1.0,
version INT NOT NULL DEFAULT 1,
created_at BIGINT NOT NULL,
updated_at BIGINT NOT NULL,
deleted_at BIGINT
);
-- 索引
CREATE INDEX idx_amr_asset_id ON asset_material_relations(asset_id) WHERE deleted_at IS NULL;
CREATE INDEX idx_amr_material_id ON asset_material_relations(material_id) WHERE deleted_at IS NULL;
CREATE INDEX idx_amr_asset_type_layer ON asset_material_relations(asset_id, material_type, layer_order) WHERE deleted_at IS NULL;
-- 部分唯一索引(软删除感知)
CREATE UNIQUE INDEX uk_amr_asset_type_active ON asset_material_relations(asset_id, material_type) WHERE deleted_at IS NULL;
CREATE UNIQUE INDEX uk_amr_asset_layer_active ON asset_material_relations(asset_id, layer_order) WHERE deleted_at IS NULL;

View File

@ -1,147 +0,0 @@
-- V7: 插入广场mock数据资产 (2026-05-17)
-- 将mockData.js中的图片数据写入assets和asset_registry表
-- 按图片顺序分配asset_id使用真实user_id循环分配
BEGIN;
-- 用户ID列表30个真实用户
-- 1, 2, 8, 13, 14, 15, 16, 17, 18, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 49, 50
-- =====================================================
-- 1. 人气榜 MOCK_RENQIWANG (22条, asset_id: 10001-10022)
-- =====================================================
INSERT INTO assets (id, owner_uid, star_id, name, cover_url, material_url, description, grade, tags, visibility, status, like_count, is_original, created_at, updated_at, is_active, material_type)
VALUES
(10001, 42, 87, '星光璀璨', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-01.png', NULL, NULL, NULL, NULL, 'public', 0, 250, false, 1773322573872, 1773322573872, true, 'hot'),
(10002, 2, 87, '爱的绽放', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-02.png', NULL, NULL, NULL, NULL, 'public', 0, 220, false, 1773322573872, 1773322573872, true, 'hot'),
(10003, 8, 87, '温暖守护', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-03.png', NULL, NULL, NULL, NULL, 'public', 0, 200, false, 1773322573872, 1773322573872, true, 'hot'),
(10004, 13, 87, '甜蜜暴击', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-04.png', NULL, NULL, NULL, NULL, 'public', 0, 180, false, 1773322573872, 1773322573872, true, 'hot'),
(10005, 14, 87, '闪耀舞台', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-05.png', NULL, NULL, NULL, NULL, 'public', 0, 150, false, 1773322573872, 1773322573872, true, 'hot'),
(10006, 15, 87, '为你疯狂', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-06.png', NULL, NULL, NULL, NULL, 'public', 0, 120, false, 1773322573872, 1773322573872, true, 'hot'),
(10007, 16, 87, '心动时刻', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-07.png', NULL, NULL, NULL, NULL, 'public', 0, 100, false, 1773322573872, 1773322573872, true, 'hot'),
(10008, 17, 87, '永相随', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-08.png', NULL, NULL, NULL, NULL, 'public', 0, 80, false, 1773322573872, 1773322573872, true, 'hot'),
(10009, 18, 87, '粉红泡泡', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-09.png', NULL, NULL, NULL, NULL, 'public', 0, 70, false, 1773322573872, 1773322573872, true, 'hot'),
(10010, 29, 87, '爱的力量', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-10.png', NULL, NULL, NULL, NULL, 'public', 0, 60, false, 1773322573872, 1773322573872, true, 'hot'),
(10011, 30, 87, '璀璨星河', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-11.png', NULL, NULL, NULL, NULL, 'public', 0, 55, false, 1773322573872, 1773322573872, true, 'hot'),
(10012, 31, 87, '梦幻泡影', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-12.png', NULL, NULL, NULL, NULL, 'public', 0, 50, false, 1773322573872, 1773322573872, true, 'hot'),
(10013, 32, 87, '温柔以待', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-13.png', NULL, NULL, NULL, NULL, 'public', 0, 45, false, 1773322573872, 1773322573872, true, 'hot'),
(10014, 33, 87, '心动信号', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-14.png', NULL, NULL, NULL, NULL, 'public', 0, 40, false, 1773322573872, 1773322573872, true, 'hot'),
(10015, 34, 87, '甜蜜时光', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-15.png', NULL, NULL, NULL, NULL, 'public', 0, 38, false, 1773322573872, 1773322573872, true, 'hot'),
(10016, 35, 87, '爱在当下', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-16.png', NULL, NULL, NULL, NULL, 'public', 0, 35, false, 1773322573872, 1773322573872, true, 'hot'),
(10017, 36, 87, '幸福味道', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-17.png', NULL, NULL, NULL, NULL, 'public', 0, 32, false, 1773322573872, 1773322573872, true, 'hot'),
(10018, 37, 87, '心动不已', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-18.png', NULL, NULL, NULL, NULL, 'public', 0, 30, false, 1773322573872, 1773322573872, true, 'hot'),
(10019, 38, 87, '爱的告白', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-19.png', NULL, NULL, NULL, NULL, 'public', 0, 28, false, 1773322573872, 1773322573872, true, 'hot'),
(10020, 39, 87, '粉色回忆', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-20.png', NULL, NULL, NULL, NULL, 'public', 0, 25, false, 1773322573872, 1773322573872, true, 'hot'),
(10021, 40, 87, '暖暖情谊', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-21.png', NULL, NULL, NULL, NULL, 'public', 0, 23, false, 1773322573872, 1773322573872, true, 'hot'),
(10022, 41, 87, '心动瞬间', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-22.png', NULL, NULL, NULL, NULL, 'public', 0, 22, false, 1773322573872, 1773322573872, true, 'hot');
-- =====================================================
-- 2. 潜力之星 MOCK_QIANLIXING (19条, asset_id: 20001-20019)
-- =====================================================
INSERT INTO assets (id, owner_uid, star_id, name, cover_url, material_url, description, grade, tags, visibility, status, like_count, is_original, created_at, updated_at, is_active, material_type)
VALUES
(20001, 42, 87, '初露锋芒', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-01.png', NULL, NULL, NULL, NULL, 'public', 0, 200, false, 1773322573872, 1773322573872, true, 'potential'),
(20002, 43, 87, '蓄势待发', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-04.png', NULL, NULL, NULL, NULL, 'public', 0, 180, false, 1773322573872, 1773322573872, true, 'potential'),
(20003, 44, 87, '冉冉升起', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-07.png', NULL, NULL, NULL, NULL, 'public', 0, 150, false, 1773322573872, 1773322573872, true, 'potential'),
(20004, 45, 87, '明日之星', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-10.png', NULL, NULL, NULL, NULL, 'public', 0, 120, false, 1773322573872, 1773322573872, true, 'potential'),
(20005, 46, 87, '潜力无限', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-13.png', NULL, NULL, NULL, NULL, 'public', 0, 100, false, 1773322573872, 1773322573872, true, 'potential'),
(20006, 47, 87, '闪耀新星', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-16.png', NULL, NULL, NULL, NULL, 'public', 0, 80, false, 1773322573872, 1773322573872, true, 'potential'),
(20007, 49, 87, '小荷才露', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-19.png', NULL, NULL, NULL, NULL, 'public', 0, 65, false, 1773322573872, 1773322573872, true, 'potential'),
(20008, 50, 87, '锋芒初现', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-22.png', NULL, NULL, NULL, NULL, 'public', 0, 55, false, 1773322573872, 1773322573872, true, 'potential'),
(20009, 43, 87, '闪闪发光', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-25.png', NULL, NULL, NULL, NULL, 'public', 0, 45, false, 1773322573872, 1773322573872, true, 'potential'),
(20010, 2, 87, '未来可期', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-28.png', NULL, NULL, NULL, NULL, 'public', 0, 38, false, 1773322573872, 1773322573872, true, 'potential'),
(20011, 8, 87, '新秀登场', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-31.png', NULL, NULL, NULL, NULL, 'public', 0, 32, false, 1773322573872, 1773322573872, true, 'potential'),
(20012, 13, 87, '星火燎原', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-34.png', NULL, NULL, NULL, NULL, 'public', 0, 28, false, 1773322573872, 1773322573872, true, 'potential'),
(20013, 14, 87, '曙光初现', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-37.png', NULL, NULL, NULL, NULL, 'public', 0, 24, false, 1773322573872, 1773322573872, true, 'potential'),
(20014, 15, 87, '新光乍现', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-40.png', NULL, NULL, NULL, NULL, 'public', 0, 20, false, 1773322573872, 1773322573872, true, 'potential'),
(20015, 16, 87, '萌芽破土', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-43.png', NULL, NULL, NULL, NULL, 'public', 0, 18, false, 1773322573872, 1773322573872, true, 'potential'),
(20016, 17, 87, '蓄力绽放', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-46.png', NULL, NULL, NULL, NULL, 'public', 0, 16, false, 1773322573872, 1773322573872, true, 'potential'),
(20017, 18, 87, '初绽光芒', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-49.png', NULL, NULL, NULL, NULL, 'public', 0, 14, false, 1773322573872, 1773322573872, true, 'potential'),
(20018, 29, 87, '潜力萌发', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-52.png', NULL, NULL, NULL, NULL, 'public', 0, 12, false, 1773322573872, 1773322573872, true, 'potential'),
(20019, 30, 87, '新生力量', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-02.png', NULL, NULL, NULL, NULL, 'public', 0, 11, false, 1773322573872, 1773322573872, true, 'potential');
-- =====================================================
-- 3. 新鲜上架 MOCK_XINXIANSHANG (27条, asset_id: 30001-30027)
-- =====================================================
INSERT INTO assets (id, owner_uid, star_id, name, cover_url, material_url, description, grade, tags, visibility, status, like_count, is_original, created_at, updated_at, is_active, material_type)
VALUES
(30001, 31, 87, '刚刚发布', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-28.png', NULL, NULL, NULL, NULL, 'public', 0, 28, false, 1773322573872, 1773322573872, true, 'new'),
(30002, 32, 87, '今日新鲜', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-29.png', NULL, NULL, NULL, NULL, 'public', 0, 25, false, 1773322573872, 1773322573872, true, 'new'),
(30003, 33, 87, '刚出锅', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-30.png', NULL, NULL, NULL, NULL, 'public', 0, 22, false, 1773322573872, 1773322573872, true, 'new'),
(30004, 34, 87, '热乎的', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-31.png', NULL, NULL, NULL, NULL, 'public', 0, 20, false, 1773322573872, 1773322573872, true, 'new'),
(30005, 35, 87, '新品上市', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-32.png', NULL, NULL, NULL, NULL, 'public', 0, 18, false, 1773322573872, 1773322573872, true, 'new'),
(30006, 36, 87, '今日首发', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-33.png', NULL, NULL, NULL, NULL, 'public', 0, 15, false, 1773322573872, 1773322573872, true, 'new'),
(30007, 37, 87, '刚出炉', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-34.png', NULL, NULL, NULL, NULL, 'public', 0, 12, false, 1773322573872, 1773322573872, true, 'new'),
(30008, 38, 87, '最新创作', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-35.png', NULL, NULL, NULL, NULL, 'public', 0, 10, false, 1773322573872, 1773322573872, true, 'new'),
(30009, 39, 87, '新鲜出炉', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-36.png', NULL, NULL, NULL, NULL, 'public', 0, 8, false, 1773322573872, 1773322573872, true, 'new'),
(30010, 40, 87, '首发作品', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-37.png', NULL, NULL, NULL, NULL, 'public', 0, 5, false, 1773322573872, 1773322573872, true, 'new'),
(30011, 41, 87, '全新上线', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-38.png', NULL, NULL, NULL, NULL, 'public', 0, 3, false, 1773322573872, 1773322573872, true, 'new'),
(30012, 42, 87, '新星登场', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-39.png', NULL, NULL, NULL, NULL, 'public', 0, 2, false, 1773322573872, 1773322573872, true, 'new'),
(30013, 43, 87, '首发惊喜', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-40.png', NULL, NULL, NULL, NULL, 'public', 0, 1, false, 1773322573872, 1773322573872, true, 'new'),
(30014, 44, 87, '今日上新', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-41.png', NULL, NULL, NULL, NULL, 'public', 0, 0, false, 1773322573872, 1773322573872, true, 'new'),
(30015, 45, 87, '新作出炉', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-42.png', NULL, NULL, NULL, NULL, 'public', 0, 0, false, 1773322573872, 1773322573872, true, 'new'),
(30016, 46, 87, '新鲜血液', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-43.png', NULL, NULL, NULL, NULL, 'public', 0, 0, false, 1773322573872, 1773322573872, true, 'new'),
(30017, 47, 87, '最新面世', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-44.png', NULL, NULL, NULL, NULL, 'public', 0, 0, false, 1773322573872, 1773322573872, true, 'new'),
(30018, 49, 87, '全新创作', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-45.png', NULL, NULL, NULL, NULL, 'public', 0, 0, false, 1773322573872, 1773322573872, true, 'new'),
(30019, 50, 87, '新晋发布', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-46.png', NULL, NULL, NULL, NULL, 'public', 0, 0, false, 1773322573872, 1773322573872, true, 'new'),
(30020, 44, 87, '新潮上线', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-47.png', NULL, NULL, NULL, NULL, 'public', 0, 0, false, 1773322573872, 1773322573872, true, 'new'),
(30021, 2, 87, '新锐登场', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-48.png', NULL, NULL, NULL, NULL, 'public', 0, 0, false, 1773322573872, 1773322573872, true, 'new'),
(30022, 8, 87, '新意满满', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-49.png', NULL, NULL, NULL, NULL, 'public', 0, 0, false, 1773322573872, 1773322573872, true, 'new'),
(30023, 13, 87, '新潮涌动', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-50.png', NULL, NULL, NULL, NULL, 'public', 0, 0, false, 1773322573872, 1773322573872, true, 'new'),
(30024, 14, 87, '新鲜感', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-51.png', NULL, NULL, NULL, NULL, 'public', 0, 0, false, 1773322573872, 1773322573872, true, 'new'),
(30025, 15, 87, '新视角', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-52.png', NULL, NULL, NULL, NULL, 'public', 0, 0, false, 1773322573872, 1773322573872, true, 'new'),
(30026, 16, 87, '新派作品', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-53.png', NULL, NULL, NULL, NULL, 'public', 0, 0, false, 1773322573872, 1773322573872, true, 'new'),
(30027, 17, 87, '新星璀璨', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-01.png', NULL, NULL, NULL, NULL, 'public', 0, 0, false, 1773322573872, 1773322573872, true, 'new');
-- =====================================================
-- 4. 随机寻宝 MOCK_SUIJIXUNBAO (37条, asset_id: 40001-40037)
-- =====================================================
INSERT INTO assets (id, owner_uid, star_id, name, cover_url, material_url, description, grade, tags, visibility, status, like_count, is_original, created_at, updated_at, is_active, material_type)
VALUES
(40001, 18, 87, '神秘宝藏1', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-18.png', NULL, NULL, NULL, NULL, 'public', 0, 35, false, 1773322573872, 1773322573872, true, 'random'),
(40002, 29, 87, '神秘宝藏2', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-05.png', NULL, NULL, NULL, NULL, 'public', 0, 140, false, 1773322573872, 1773322573872, true, 'random'),
(40003, 30, 87, '神秘宝藏3', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-31.png', NULL, NULL, NULL, NULL, 'public', 0, 0, false, 1773322573872, 1773322573872, true, 'random'),
(40004, 31, 87, '神秘宝藏4', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-12.png', NULL, NULL, NULL, NULL, 'public', 0, 68, false, 1773322573872, 1773322573872, true, 'random'),
(40005, 32, 87, '神秘宝藏5', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-02.png', NULL, NULL, NULL, NULL, 'public', 0, 210, false, 1773322573872, 1773322573872, true, 'random'),
(40006, 33, 87, '神秘宝藏6', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-25.png', NULL, NULL, NULL, NULL, 'public', 0, 12, false, 1773322573872, 1773322573872, true, 'random'),
(40007, 34, 87, '神秘宝藏7', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-09.png', NULL, NULL, NULL, NULL, 'public', 0, 95, false, 1773322573872, 1773322573872, true, 'random'),
(40008, 35, 87, '神秘宝藏8', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-36.png', NULL, NULL, NULL, NULL, 'public', 0, 0, false, 1773322573872, 1773322573872, true, 'random'),
(40009, 36, 87, '神秘宝藏9', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-20.png', NULL, NULL, NULL, NULL, 'public', 0, 28, false, 1773322573872, 1773322573872, true, 'random'),
(40010, 37, 87, '神秘宝藏10', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-07.png', NULL, NULL, NULL, NULL, 'public', 0, 110, false, 1773322573872, 1773322573872, true, 'random'),
(40011, 38, 87, '神秘宝藏11', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-33.png', NULL, NULL, NULL, NULL, 'public', 0, 0, false, 1773322573872, 1773322573872, true, 'random'),
(40012, 39, 87, '神秘宝藏12', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-14.png', NULL, NULL, NULL, NULL, 'public', 0, 55, false, 1773322573872, 1773322573872, true, 'random'),
(40013, 40, 87, '神秘宝藏13', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-01.png', NULL, NULL, NULL, NULL, 'public', 0, 230, false, 1773322573872, 1773322573872, true, 'random'),
(40014, 41, 87, '神秘宝藏14', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-28.png', NULL, NULL, NULL, NULL, 'public', 0, 5, false, 1773322573872, 1773322573872, true, 'random'),
(40015, 42, 87, '神秘宝藏15', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-22.png', NULL, NULL, NULL, NULL, 'public', 0, 22, false, 1773322573872, 1773322573872, true, 'random'),
(40016, 43, 87, '神秘宝藏16', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-10.png', NULL, NULL, NULL, NULL, 'public', 0, 88, false, 1773322573872, 1773322573872, true, 'random'),
(40017, 44, 87, '神秘宝藏17', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-35.png', NULL, NULL, NULL, NULL, 'public', 0, 0, false, 1773322573872, 1773322573872, true, 'random'),
(40018, 45, 87, '神秘宝藏18', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-16.png', NULL, NULL, NULL, NULL, 'public', 0, 42, false, 1773322573872, 1773322573872, true, 'random'),
(40019, 46, 87, '神秘宝藏19', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-03.png', NULL, NULL, NULL, NULL, 'public', 0, 185, false, 1773322573872, 1773322573872, true, 'random'),
(40020, 47, 87, '神秘宝藏20', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-29.png', NULL, NULL, NULL, NULL, 'public', 0, 3, false, 1773322573872, 1773322573872, true, 'random'),
(40021, 49, 87, '神秘宝藏21', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-08.png', NULL, NULL, NULL, NULL, 'public', 0, 105, false, 1773322573872, 1773322573872, true, 'random'),
(40022, 50, 87, '神秘宝藏22', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-24.png', NULL, NULL, NULL, NULL, 'public', 0, 15, false, 1773322573872, 1773322573872, true, 'random'),
(40023, 45, 87, '神秘宝藏23', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-11.png', NULL, NULL, NULL, NULL, 'public', 0, 75, false, 1773322573872, 1773322573872, true, 'random'),
(40024, 2, 87, '神秘宝藏24', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-34.png', NULL, NULL, NULL, NULL, 'public', 0, 0, false, 1773322573872, 1773322573872, true, 'random'),
(40025, 8, 87, '神秘宝藏25', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-19.png', NULL, NULL, NULL, NULL, 'public', 0, 32, false, 1773322573872, 1773322573872, true, 'random'),
(40026, 13, 87, '神秘宝藏26', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-30.png', NULL, NULL, NULL, NULL, 'public', 0, 2, false, 1773322573872, 1773322573872, true, 'random'),
(40027, 14, 87, '神秘宝藏27', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-06.png', NULL, NULL, NULL, NULL, 'public', 0, 120, false, 1773322573872, 1773322573872, true, 'random'),
(40028, 15, 87, '神秘宝藏28', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-27.png', NULL, NULL, NULL, NULL, 'public', 0, 8, false, 1773322573872, 1773322573872, true, 'random'),
(40029, 16, 87, '神秘宝藏29', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-23.png', NULL, NULL, NULL, NULL, 'public', 0, 18, false, 1773322573872, 1773322573872, true, 'random'),
(40030, 17, 87, '神秘宝藏30', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-04.png', NULL, NULL, NULL, NULL, 'public', 0, 160, false, 1773322573872, 1773322573872, true, 'random'),
(40031, 18, 87, '神秘宝藏31', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-32.png', NULL, NULL, NULL, NULL, 'public', 0, 0, false, 1773322573872, 1773322573872, true, 'random'),
(40032, 29, 87, '神秘宝藏32', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-13.png', NULL, NULL, NULL, NULL, 'public', 0, 62, false, 1773322573872, 1773322573872, true, 'random'),
(40033, 30, 87, '神秘宝藏33', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-37.png', NULL, NULL, NULL, NULL, 'public', 0, 0, false, 1773322573872, 1773322573872, true, 'random'),
(40034, 31, 87, '神秘宝藏34', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-21.png', NULL, NULL, NULL, NULL, 'public', 0, 25, false, 1773322573872, 1773322573872, true, 'random'),
(40035, 32, 87, '神秘宝藏35', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-35.png', NULL, NULL, NULL, NULL, 'public', 0, 0, false, 1773322573872, 1773322573872, true, 'random'),
(40036, 33, 87, '神秘宝藏36', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-17.png', NULL, NULL, NULL, NULL, 'public', 0, 38, false, 1773322573872, 1773322573872, true, 'random'),
(40037, 34, 87, '神秘宝藏37', 'https://top-fans-test.oss-cn-shanghai.aliyuncs.com/asset/1/87/image-26.png', NULL, NULL, NULL, NULL, 'public', 0, 10, false, 1773322573872, 1773322573872, true, 'random');
-- =====================================================
-- 5. 批量插入 asset_registry 记录
-- =====================================================
INSERT INTO asset_registry (id, asset_id, asset_type, owner_uid, star_id, grade, collection_category, activity_id, activity_type, status, like_count, display_status, created_at, updated_at)
SELECT id, id, 'artwork', owner_uid, star_id, NULL, NULL, NULL, NULL, 0, like_count, 0, 1773322573872, 1773322573872
FROM assets
WHERE id >= 10000;
COMMIT;

View File

@ -1,46 +0,0 @@
-- V8: 将mock资产插入展示表exhibitions (2026-05-17)
-- 为所有mock资产(asset_id: 10001-40037)创建展示记录
-- 结束时间 = 开始时间 + 1个月
BEGIN;
-- 获取当前时间戳(毫秒)作为开始时间
DO $$
DECLARE
start_ts bigint := (EXTRACT(EPOCH FROM NOW()) * 1000)::bigint;
expire_ts bigint := (EXTRACT(EPOCH FROM NOW()) * 1000)::bigint + (30::bigint * 24 * 60 * 60 * 1000); -- 加1个月
slot_ids bigint[];
slot_rec record;
asset_rec record;
i int := 0;
BEGIN
-- 收集star_id=87的所有可用slot_id排除已被用户1占用的
SELECT array_agg(slot_id ORDER BY slot_id) INTO slot_ids
FROM booth_slots
WHERE star_id = 87
AND slot_id NOT IN (SELECT slot_id FROM exhibitions WHERE occupier_uid = 1 AND deleted_at IS NULL);
-- 为每个mock资产创建展示记录
FOR asset_rec IN SELECT id, owner_uid FROM assets WHERE id >= 10000 ORDER BY id LOOP
-- 循环分配slot_id
IF array_length(slot_ids, 1) > 0 THEN
i := (i % array_length(slot_ids, 1)) + 1;
-- 获取对应slot的host_profile_id
SELECT host_profile_id INTO slot_rec FROM booth_slots WHERE slot_id = slot_ids[i];
INSERT INTO exhibitions (asset_id, slot_id, host_profile_id, occupier_uid, occupier_star_id, start_time, expire_at, created_at, updated_at)
VALUES (asset_rec.id, slot_ids[i], slot_rec.host_profile_id, asset_rec.owner_uid, 87, start_ts, expire_ts, start_ts, start_ts)
ON CONFLICT (asset_id) WHERE deleted_at IS NULL DO NOTHING;
END IF;
END LOOP;
END $$;
-- 将asset_registry的display_status设为1
UPDATE asset_registry SET display_status = 1 WHERE id >= 10000;
UPDATE asset_registry SET status = 1 WHERE id >= 10000 AND display_status = 1;
UPDATE assets SET status = 1 WHERE star_id = 87 AND status = 0;
COMMIT;

View File

@ -1,280 +0,0 @@
-- V9: 添加缺失的经济系统和等级系统表 (2026-05-18)
-- 服务器数据库缺少以下表: user_mint_count, mint_cost_config, level_*, transaction_records, mint_*_config
BEGIN;
-- =====================================================
-- 1. user_mint_count 铸爱次数表 (V5原有)
-- =====================================================
CREATE TABLE IF NOT EXISTS public.user_mint_count (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL,
star_id BIGINT NOT NULL,
mint_count INT NOT NULL DEFAULT 0,
revenue_boost_bps INT NOT NULL DEFAULT 0,
updated_at BIGINT NOT NULL,
CONSTRAINT uk_user_mint_count_user_star UNIQUE (user_id, star_id)
);
CREATE INDEX IF NOT EXISTS idx_user_mint_count_user ON public.user_mint_count USING btree (user_id);
CREATE INDEX IF NOT EXISTS idx_user_mint_count_star ON public.user_mint_count USING btree (star_id);
COMMENT ON TABLE public.user_mint_count IS '用户在某偶像下的累计铸爱次数与收益加成(基点)';
-- =====================================================
-- 2. mint_cost_config 铸爱阶梯配置表 (V5原有)
-- =====================================================
CREATE TABLE IF NOT EXISTS public.mint_cost_config (
id BIGSERIAL PRIMARY KEY,
mint_count INT NOT NULL,
cost_crystal BIGINT NOT NULL,
probability BIGINT NOT NULL DEFAULT 0,
reward_type VARCHAR(50) DEFAULT NULL,
reward_value BIGINT NOT NULL DEFAULT 0,
description VARCHAR(255),
updated_at BIGINT NOT NULL,
CONSTRAINT uk_mint_cost_config_mint_count UNIQUE (mint_count)
);
COMMENT ON TABLE public.mint_cost_config IS '铸爱次数阶梯消耗与保底配置';
-- 插入铸爱阶梯数据
INSERT INTO public.mint_cost_config (mint_count, cost_crystal, probability, reward_type, reward_value, description, updated_at)
VALUES
(1, 2, 0, NULL, 0, '第1次', 1773322573872),
(2, 4, 0, NULL, 0, '第2次', 1773322573872),
(3, 8, 0, NULL, 0, '第3次', 1773322573872),
(4, 16, 0, NULL, 0, '第4次', 1773322573872),
(5, 32, 0, NULL, 0, '第5次', 1773322573872),
(6, 64, 0, NULL, 0, '第6次', 1773322573872),
(7, 128, 0, NULL, 0, '第7次', 1773322573872),
(8, 256, 0, NULL, 0, '第8次', 1773322573872),
(9, 512, 20, '收益提升', 5, '小保底', 1773322573872),
(10, 1024, 100, '收益提升', 5, '大保底', 1773322573872)
ON CONFLICT (mint_count) DO UPDATE SET
cost_crystal = EXCLUDED.cost_crystal,
probability = EXCLUDED.probability,
reward_type = EXCLUDED.reward_type,
reward_value = EXCLUDED.reward_value,
description = EXCLUDED.description,
updated_at = EXCLUDED.updated_at;
-- =====================================================
-- 3. level_thresholds 等级阈值表
-- =====================================================
CREATE TABLE IF NOT EXISTS public.level_thresholds (
id BIGSERIAL PRIMARY KEY,
level INT NOT NULL,
exp_requirement BIGINT NOT NULL DEFAULT 0,
title VARCHAR(50),
badge_url VARCHAR(500),
privileges JSONB,
updated_at BIGINT NOT NULL,
CONSTRAINT uk_level_thresholds_level UNIQUE (level)
);
COMMENT ON TABLE public.level_thresholds IS '等级阈值配置表';
-- =====================================================
-- 4. level_up_reward_config 升级奖励配置表
-- =====================================================
CREATE TABLE IF NOT EXISTS public.level_up_reward_config (
id BIGSERIAL PRIMARY KEY,
level INT NOT NULL,
reward_type VARCHAR(50) NOT NULL,
reward_amount BIGINT NOT NULL DEFAULT 0,
description VARCHAR(255),
updated_at BIGINT NOT NULL,
CONSTRAINT uk_level_up_reward_level_type UNIQUE (level, reward_type)
);
COMMENT ON TABLE public.level_up_reward_config IS '升级奖励配置表';
-- =====================================================
-- 5. level_upgrade_conditions 升级条件表
-- =====================================================
CREATE TABLE IF NOT EXISTS public.level_upgrade_conditions (
id BIGSERIAL PRIMARY KEY,
level INT NOT NULL,
condition_type VARCHAR(50) NOT NULL,
condition_value BIGINT NOT NULL DEFAULT 0,
description VARCHAR(255),
updated_at BIGINT NOT NULL,
CONSTRAINT uk_level_upgrade_conditions_level_type UNIQUE (level, condition_type)
);
COMMENT ON TABLE public.level_upgrade_conditions IS '升级条件配置表';
-- =====================================================
-- 6. dazi_level_thresholds 靶子等级阈值表
-- =====================================================
CREATE TABLE IF NOT EXISTS public.dazi_level_thresholds (
id BIGSERIAL PRIMARY KEY,
level INT NOT NULL,
exp_requirement BIGINT NOT NULL DEFAULT 0,
title VARCHAR(50),
updated_at BIGINT NOT NULL,
CONSTRAINT uk_dazi_level_thresholds_level UNIQUE (level)
);
COMMENT ON TABLE public.dazi_level_thresholds IS '靶子等级阈值配置表';
-- =====================================================
-- 7. level_cap_config 等级上限配置表
-- =====================================================
CREATE TABLE IF NOT EXISTS public.level_cap_config (
id BIGSERIAL PRIMARY KEY,
star_id BIGINT NOT NULL,
max_level INT NOT NULL DEFAULT 50,
exp_multiplier DECIMAL(5,2) NOT NULL DEFAULT 1.0,
updated_at BIGINT NOT NULL,
CONSTRAINT uk_level_cap_config_star UNIQUE (star_id)
);
COMMENT ON TABLE public.level_cap_config IS '等级上限配置表';
-- =====================================================
-- 8. user_dazi_level 用户靶子等级表
-- =====================================================
CREATE TABLE IF NOT EXISTS public.user_dazi_level (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL,
star_id BIGINT NOT NULL,
level INT NOT NULL DEFAULT 1,
exp BIGINT NOT NULL DEFAULT 0,
updated_at BIGINT NOT NULL,
CONSTRAINT uk_user_dazi_level_user_star UNIQUE (user_id, star_id)
);
CREATE INDEX IF NOT EXISTS idx_user_dazi_level_user ON public.user_dazi_level USING btree (user_id);
CREATE INDEX IF NOT EXISTS idx_user_dazi_level_star ON public.user_dazi_level USING btree (star_id);
COMMENT ON TABLE public.user_dazi_level IS '用户在某偶像下的靶子等级和经验';
-- =====================================================
-- 9. coin_transaction_records 金币交易记录表
-- =====================================================
CREATE TABLE IF NOT EXISTS public.coin_transaction_records (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL,
star_id BIGINT NOT NULL,
transaction_type VARCHAR(50) NOT NULL,
amount BIGINT NOT NULL,
balance_before BIGINT NOT NULL,
balance_after BIGINT NOT NULL,
reference_id VARCHAR(100),
reference_type VARCHAR(50),
description VARCHAR(255),
created_at BIGINT NOT NULL,
CONSTRAINT uk_coin_transaction_records_id UNIQUE (id)
);
CREATE INDEX IF NOT EXISTS idx_coin_transaction_records_user ON public.coin_transaction_records USING btree (user_id);
CREATE INDEX IF NOT EXISTS idx_coin_transaction_records_star ON public.coin_transaction_records USING btree (star_id);
CREATE INDEX IF NOT EXISTS idx_coin_transaction_records_created ON public.coin_transaction_records USING btree (created_at DESC);
COMMENT ON TABLE public.coin_transaction_records IS '金币交易记录表';
-- =====================================================
-- 10. crystal_transaction_records 水晶交易记录表
-- =====================================================
CREATE TABLE IF NOT EXISTS public.crystal_transaction_records (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL,
star_id BIGINT NOT NULL,
change_type VARCHAR(50) NOT NULL,
delta BIGINT NOT NULL,
balance_before BIGINT NOT NULL,
balance_after BIGINT NOT NULL,
source_id VARCHAR(100),
reference_type VARCHAR(50),
description VARCHAR(255),
created_at BIGINT NOT NULL,
CONSTRAINT uk_crystal_transaction_records_id UNIQUE (id)
);
CREATE INDEX IF NOT EXISTS idx_crystal_transaction_records_user ON public.crystal_transaction_records USING btree (user_id);
CREATE INDEX IF NOT EXISTS idx_crystal_transaction_records_star ON public.crystal_transaction_records USING btree (star_id);
CREATE INDEX IF NOT EXISTS idx_crystal_transaction_records_created ON public.crystal_transaction_records USING btree (created_at DESC);
COMMENT ON TABLE public.crystal_transaction_records IS '水晶交易记录表';
-- =====================================================
-- 11. mint_reward_config 铸爱奖励配置表
-- =====================================================
CREATE TABLE IF NOT EXISTS public.mint_reward_config (
id BIGSERIAL PRIMARY KEY,
mint_count INT NOT NULL,
reward_type VARCHAR(50) NOT NULL,
reward_amount BIGINT NOT NULL DEFAULT 0,
probability BIGINT NOT NULL DEFAULT 0,
description VARCHAR(255),
updated_at BIGINT NOT NULL,
CONSTRAINT uk_mint_reward_config_mint_count_type UNIQUE (mint_count, reward_type)
);
COMMENT ON TABLE public.mint_reward_config IS '铸爱奖励配置表';
-- =====================================================
-- 12. mint_milestone_config 铸爱里程碑配置表
-- =====================================================
CREATE TABLE IF NOT EXISTS public.mint_milestone_config (
id BIGSERIAL PRIMARY KEY,
milestone INT NOT NULL,
reward_type VARCHAR(50) NOT NULL,
reward_amount BIGINT NOT NULL DEFAULT 0,
description VARCHAR(255),
updated_at BIGINT NOT NULL,
CONSTRAINT uk_mint_milestone_config_milestone UNIQUE (milestone)
);
COMMENT ON TABLE public.mint_milestone_config IS '铸爱里程碑配置表';
COMMIT;
-- 插入默认等级阈值数据
INSERT INTO public.level_thresholds (level, exp_requirement, title, badge_url, privileges, updated_at)
VALUES
(1, 0, '初入星途', NULL, NULL, 1773322573872),
(2, 100, '小小星星', NULL, NULL, 1773322573872),
(3, 300, '新星闪耀', NULL, NULL, 1773322573872),
(4, 600, '潜力新星', NULL, NULL, 1773322573872),
(5, 1000, '明日之星', NULL, NULL, 1773322573872),
(6, 1500, '冉冉升起', NULL, NULL, 1773322573872),
(7, 2100, '星光熠熠', NULL, NULL, 1773322573872),
(8, 2800, '璀璨星辰', NULL, NULL, 1773322573872),
(9, 3600, '星途璀璨', NULL, NULL, 1773322573872),
(10, 4500, '超级新星', NULL, NULL, 1773322573872)
ON CONFLICT (level) DO UPDATE SET
exp_requirement = EXCLUDED.exp_requirement,
title = EXCLUDED.title,
badge_url = EXCLUDED.badge_url,
privileges = EXCLUDED.privileges,
updated_at = EXCLUDED.updated_at;
-- 插入默认靶子等级阈值数据
INSERT INTO public.dazi_level_thresholds (level, exp_requirement, title, updated_at)
VALUES
(1, 0, '初级靶子', 1773322573872),
(2, 50, '中级靶子', 1773322573872),
(3, 150, '高级靶子', 1773322573872),
(4, 300, '超级靶子', 1773322573872),
(5, 500, '终极靶子', 1773322573872)
ON CONFLICT (level) DO UPDATE SET
exp_requirement = EXCLUDED.exp_requirement,
title = EXCLUDED.title,
updated_at = EXCLUDED.updated_at;
-- 插入铸爱里程碑配置
INSERT INTO public.mint_milestone_config (milestone, reward_type, reward_amount, description, updated_at)
VALUES
(10, '称号', 1, '铸爱达人', 1773322573872),
(50, '称号', 2, '铸爱巨星', 1773322573872),
(100, '称号', 3, '铸爱传奇', 1773322573872),
(200, '称号', 4, '铸爱神话', 1773322573872),
(500, '称号', 5, '铸爱永恒', 1773322573872)
ON CONFLICT (milestone) DO UPDATE SET
reward_type = EXCLUDED.reward_type,
reward_amount = EXCLUDED.reward_amount,
description = EXCLUDED.description,
updated_at = EXCLUDED.updated_at;

View File

@ -2,8 +2,8 @@
"name" : "TopFans",
"appid" : "__UNI__F199FF4",
"description" : "",
"versionName" : "1.1.0",
"versionCode" : 101,
"versionName" : "1.0.5",
"versionCode" : 100,
"transformPx" : false,
/* 5+App */
"app-plus" : {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 798 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 163 KiB