-- Dumped from database version 18.1 (Debian 18.1-1.pgdg13+2) -- Dumped by pg_dump version 18.1 (Debian 18.1-1.pgdg13+2) SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; SET transaction_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SELECT pg_catalog.set_config('search_path', '', false); SET check_function_bodies = false; SET xmloption = content; SET client_min_messages = warning; SET row_security = off; -- -- Name: uuid-ossp; Type: EXTENSION; Schema: -; Owner: - -- CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public; -- -- Name: EXTENSION "uuid-ossp"; Type: COMMENT; Schema: -; Owner: - -- COMMENT ON EXTENSION "uuid-ossp" IS 'generate universally unique identifiers (UUIDs)'; SET default_tablespace = ''; SET default_table_access_method = heap; -- -- Name: activities; Type: TABLE; Schema: public; Owner: - -- 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 ); -- -- Name: TABLE activities; Type: COMMENT; Schema: public; Owner: - -- COMMENT ON TABLE public.activities IS '运营活动表'; -- -- Name: activities_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.activities_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: activities_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.activities_id_seq OWNED BY public.activities.id; -- -- Name: activity_contributions; Type: TABLE; Schema: public; Owner: - -- 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 ); -- -- Name: TABLE activity_contributions; Type: COMMENT; Schema: public; Owner: - -- COMMENT ON TABLE public.activity_contributions IS '用户活动贡献记录表'; -- -- Name: activity_contributions_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.activity_contributions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: activity_contributions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.activity_contributions_id_seq OWNED BY public.activity_contributions.id; -- -- Name: activity_items; Type: TABLE; Schema: public; Owner: - -- 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 ); -- -- Name: TABLE activity_items; Type: COMMENT; Schema: public; Owner: - -- COMMENT ON TABLE public.activity_items IS '活动道具表'; -- -- Name: activity_items_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.activity_items_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: activity_items_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.activity_items_id_seq OWNED BY public.activity_items.id; -- -- Name: activity_user_stats; Type: TABLE; Schema: public; Owner: - -- 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 ); -- -- Name: TABLE activity_user_stats; Type: COMMENT; Schema: public; Owner: - -- COMMENT ON TABLE public.activity_user_stats IS '用户活动贡献汇总表'; -- -- Name: activity_user_stats_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.activity_user_stats_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: activity_user_stats_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.activity_user_stats_id_seq OWNED BY public.activity_user_stats.id; -- -- Name: asset_likes; Type: TABLE; Schema: public; Owner: - -- 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 ); -- -- Name: TABLE asset_likes; Type: COMMENT; Schema: public; Owner: - -- COMMENT ON TABLE public.asset_likes IS '点赞记录表'; -- -- Name: asset_likes_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.asset_likes_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: asset_likes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.asset_likes_id_seq OWNED BY public.asset_likes.id; -- -- Name: asset_registry; Type: TABLE; Schema: public; Owner: - -- 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 ); -- -- Name: TABLE asset_registry; Type: COMMENT; Schema: public; Owner: - -- COMMENT ON TABLE public.asset_registry IS '资产注册表(星册体系)'; -- -- Name: asset_registry_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.asset_registry_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: asset_registry_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.asset_registry_id_seq OWNED BY public.asset_registry.id; -- -- Name: assets; Type: TABLE; Schema: public; Owner: - -- 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 ); -- -- Name: TABLE assets; Type: COMMENT; Schema: public; Owner: - -- COMMENT ON TABLE public.assets IS '资产表(藏品)'; -- -- Name: assets_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.assets_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: assets_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.assets_id_seq OWNED BY public.assets.id; -- -- Name: booth_slots; Type: TABLE; Schema: public; Owner: - -- 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 ); -- -- Name: TABLE booth_slots; Type: COMMENT; Schema: public; Owner: - -- COMMENT ON TABLE public.booth_slots IS '展位表'; -- -- Name: booth_slots_slot_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.booth_slots_slot_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: booth_slots_slot_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.booth_slots_slot_id_seq OWNED BY public.booth_slots.slot_id; -- -- Name: exhibition_revenue_records; Type: TABLE; Schema: public; Owner: - -- 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 ); -- -- Name: exhibition_revenue_records_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.exhibition_revenue_records_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: exhibition_revenue_records_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.exhibition_revenue_records_id_seq OWNED BY public.exhibition_revenue_records.id; -- -- Name: exhibitions; Type: TABLE; Schema: public; Owner: - -- 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 ); -- -- Name: TABLE exhibitions; Type: COMMENT; Schema: public; Owner: - -- COMMENT ON TABLE public.exhibitions IS '展品展示表'; -- -- Name: exhibitions_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.exhibitions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: exhibitions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.exhibitions_id_seq OWNED BY public.exhibitions.id; -- -- Name: fan_profiles; Type: TABLE; Schema: public; Owner: - -- 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) ); -- -- Name: TABLE fan_profiles; Type: COMMENT; Schema: public; Owner: - -- COMMENT ON TABLE public.fan_profiles IS '粉丝档案表'; -- -- Name: fan_profiles_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.fan_profiles_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: fan_profiles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.fan_profiles_id_seq OWNED BY public.fan_profiles.id; -- -- Name: friend_requests; Type: TABLE; Schema: public; Owner: - -- 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 ); -- -- Name: TABLE friend_requests; Type: COMMENT; Schema: public; Owner: - -- COMMENT ON TABLE public.friend_requests IS '好友请求表'; -- -- Name: friend_requests_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.friend_requests_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: friend_requests_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.friend_requests_id_seq OWNED BY public.friend_requests.id; -- -- Name: friendships; Type: TABLE; Schema: public; Owner: - -- 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 ); -- -- Name: TABLE friendships; Type: COMMENT; Schema: public; Owner: - -- COMMENT ON TABLE public.friendships IS '好友关系表'; -- -- Name: friendships_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.friendships_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: friendships_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.friendships_id_seq OWNED BY public.friendships.id; -- -- Name: mint_orders; Type: TABLE; Schema: public; Owner: - -- 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 ); -- -- Name: TABLE mint_orders; Type: COMMENT; Schema: public; Owner: - -- COMMENT ON TABLE public.mint_orders IS '铸造订单表'; -- -- Name: stars; Type: TABLE; Schema: public; Owner: - -- 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 ); -- -- Name: TABLE stars; Type: COMMENT; Schema: public; Owner: - -- COMMENT ON TABLE public.stars IS '明星信息表'; -- -- Name: stars_star_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.stars_star_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: stars_star_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.stars_star_id_seq OWNED BY public.stars.star_id; -- -- Name: task_definitions; Type: TABLE; Schema: public; Owner: - -- 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 ); -- -- Name: task_definitions_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.task_definitions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: task_definitions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.task_definitions_id_seq OWNED BY public.task_definitions.id; -- -- Name: user_onboarding_status; Type: TABLE; Schema: public; Owner: - -- 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 ); -- -- Name: user_onboarding_status_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.user_onboarding_status_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: user_onboarding_status_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.user_onboarding_status_id_seq OWNED BY public.user_onboarding_status.id; -- -- Name: user_task_progress; Type: TABLE; Schema: public; Owner: - -- 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 ); -- -- Name: user_task_progress_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.user_task_progress_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: user_task_progress_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.user_task_progress_id_seq OWNED BY public.user_task_progress.id; -- -- Name: users; Type: TABLE; Schema: public; Owner: - -- 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 ); -- -- Name: TABLE users; Type: COMMENT; Schema: public; Owner: - -- COMMENT ON TABLE public.users IS '用户表'; -- -- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.users_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id; -- -- Name: activities id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.activities ALTER COLUMN id SET DEFAULT nextval('public.activities_id_seq'::regclass); -- -- Name: activity_contributions id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.activity_contributions ALTER COLUMN id SET DEFAULT nextval('public.activity_contributions_id_seq'::regclass); -- -- Name: activity_items id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.activity_items ALTER COLUMN id SET DEFAULT nextval('public.activity_items_id_seq'::regclass); -- -- Name: activity_user_stats id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.activity_user_stats ALTER COLUMN id SET DEFAULT nextval('public.activity_user_stats_id_seq'::regclass); -- -- Name: asset_likes id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.asset_likes ALTER COLUMN id SET DEFAULT nextval('public.asset_likes_id_seq'::regclass); -- -- Name: asset_registry id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.asset_registry ALTER COLUMN id SET DEFAULT nextval('public.asset_registry_id_seq'::regclass); -- -- Name: assets id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.assets ALTER COLUMN id SET DEFAULT nextval('public.assets_id_seq'::regclass); -- -- Name: asset_registry id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.asset_registry ALTER COLUMN id SET DEFAULT nextval('public.asset_registry_id_seq'::regclass); -- -- Name: booth_slots slot_id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.booth_slots ALTER COLUMN slot_id SET DEFAULT nextval('public.booth_slots_slot_id_seq'::regclass); -- -- Name: exhibition_revenue_records id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.exhibition_revenue_records ALTER COLUMN id SET DEFAULT nextval('public.exhibition_revenue_records_id_seq'::regclass); -- -- Name: exhibitions id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.exhibitions ALTER COLUMN id SET DEFAULT nextval('public.exhibitions_id_seq'::regclass); -- -- Name: fan_profiles id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.fan_profiles ALTER COLUMN id SET DEFAULT nextval('public.fan_profiles_id_seq'::regclass); -- -- Name: friend_requests id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.friend_requests ALTER COLUMN id SET DEFAULT nextval('public.friend_requests_id_seq'::regclass); -- -- Name: friendships id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.friendships ALTER COLUMN id SET DEFAULT nextval('public.friendships_id_seq'::regclass); -- -- Name: stars star_id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.stars ALTER COLUMN star_id SET DEFAULT nextval('public.stars_star_id_seq'::regclass); -- -- Name: task_definitions id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.task_definitions ALTER COLUMN id SET DEFAULT nextval('public.task_definitions_id_seq'::regclass); -- -- Name: user_onboarding_status id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.user_onboarding_status ALTER COLUMN id SET DEFAULT nextval('public.user_onboarding_status_id_seq'::regclass); -- -- Name: user_task_progress id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.user_task_progress ALTER COLUMN id SET DEFAULT nextval('public.user_task_progress_id_seq'::regclass); -- -- Name: users id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass); -- -- Name: activities activities_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.activities ADD CONSTRAINT activities_pkey PRIMARY KEY (id); -- -- Name: activity_contributions activity_contributions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.activity_contributions ADD CONSTRAINT activity_contributions_pkey PRIMARY KEY (id); -- -- Name: activity_items activity_items_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.activity_items ADD CONSTRAINT activity_items_pkey PRIMARY KEY (id); -- -- Name: activity_user_stats activity_user_stats_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.activity_user_stats ADD CONSTRAINT activity_user_stats_pkey PRIMARY KEY (id); -- -- Name: asset_likes asset_likes_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.asset_likes ADD CONSTRAINT asset_likes_pkey PRIMARY KEY (id); -- -- Name: asset_registry asset_registry_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.asset_registry ADD CONSTRAINT asset_registry_pkey PRIMARY KEY (id); -- -- Name: assets assets_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.assets ADD CONSTRAINT assets_pkey PRIMARY KEY (id); -- -- Name: booth_slots booth_slots_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.booth_slots ADD CONSTRAINT booth_slots_pkey PRIMARY KEY (slot_id); -- -- Name: exhibition_revenue_records exhibition_revenue_records_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.exhibition_revenue_records ADD CONSTRAINT exhibition_revenue_records_pkey PRIMARY KEY (id); -- -- Name: exhibitions exhibitions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.exhibitions ADD CONSTRAINT exhibitions_pkey PRIMARY KEY (id); -- -- Name: fan_profiles fan_profiles_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.fan_profiles ADD CONSTRAINT fan_profiles_pkey PRIMARY KEY (id); -- -- Name: friend_requests friend_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.friend_requests ADD CONSTRAINT friend_requests_pkey PRIMARY KEY (id); -- -- Name: friendships friendships_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.friendships ADD CONSTRAINT friendships_pkey PRIMARY KEY (id); -- -- Name: mint_orders mint_orders_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.mint_orders ADD CONSTRAINT mint_orders_pkey PRIMARY KEY (order_id); -- -- Name: stars stars_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.stars ADD CONSTRAINT stars_pkey PRIMARY KEY (star_id); -- -- Name: task_definitions task_definitions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.task_definitions ADD CONSTRAINT task_definitions_pkey PRIMARY KEY (id); -- -- Name: activity_user_stats uk_activity_user_star; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.activity_user_stats ADD CONSTRAINT uk_activity_user_star UNIQUE (activity_id, user_id, star_id); -- -- Name: asset_likes uk_asset_likes_user_asset_exhibition; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.asset_likes ADD CONSTRAINT uk_asset_likes_user_asset_exhibition UNIQUE (user_id, asset_id, exhibition_id); -- -- Name: user_onboarding_status user_onboarding_status_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.user_onboarding_status ADD CONSTRAINT user_onboarding_status_pkey PRIMARY KEY (id); -- -- Name: user_task_progress user_task_progress_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.user_task_progress ADD CONSTRAINT user_task_progress_pkey PRIMARY KEY (id); -- -- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.users ADD CONSTRAINT users_pkey PRIMARY KEY (id); -- -- Name: idx_activities_star_id; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_activities_star_id ON public.activities USING btree (star_id); -- -- Name: idx_activities_start_end; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_activities_start_end ON public.activities USING btree (start_time, end_time); -- -- Name: idx_activities_status; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_activities_status ON public.activities USING btree (status); -- -- Name: idx_activity_contributions_activity; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_activity_contributions_activity ON public.activity_contributions USING btree (activity_id); -- -- Name: idx_activity_contributions_created; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_activity_contributions_created ON public.activity_contributions USING btree (created_at DESC); -- -- Name: idx_activity_contributions_user_star; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_activity_contributions_user_star ON public.activity_contributions USING btree (user_id, star_id); -- -- Name: idx_activity_items_activity; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_activity_items_activity ON public.activity_items USING btree (activity_id); -- -- Name: idx_activity_items_type; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_activity_items_type ON public.activity_items USING btree (item_type); -- -- Name: idx_activity_user_stats_activity; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_activity_user_stats_activity ON public.activity_user_stats USING btree (activity_id); -- -- Name: idx_activity_user_stats_contribution; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_activity_user_stats_contribution ON public.activity_user_stats USING btree (activity_id, total_contribution DESC); -- -- Name: idx_activity_user_stats_user_star; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_activity_user_stats_user_star ON public.activity_user_stats USING btree (user_id, star_id); -- -- Name: idx_asset_likes_asset; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_asset_likes_asset ON public.asset_likes USING btree (asset_id); -- -- Name: idx_asset_likes_user_star; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_asset_likes_user_star ON public.asset_likes USING btree (user_id, star_id); -- -- Name: idx_asset_likes_asset_created; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX IF NOT EXISTS idx_asset_likes_asset_created ON public.asset_likes USING btree (asset_id, created_at DESC); -- -- Name: idx_registry_owner_star; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_registry_owner_star ON public.asset_registry USING btree (owner_uid, star_id); -- -- Name: idx_assets_created_at; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_assets_created_at ON public.assets USING btree (created_at DESC); -- -- Name: idx_assets_deleted_at; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_assets_deleted_at ON public.assets USING btree (deleted_at); -- -- Name: idx_assets_owner_star; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_assets_owner_star ON public.assets USING btree (owner_uid, star_id); -- -- Name: idx_assets_star_active; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_assets_star_active ON public.assets USING btree (star_id, is_active); -- -- Name: idx_assets_status; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_assets_status ON public.assets USING btree (status); -- -- Name: idx_assets_tx_hash; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_assets_tx_hash ON public.assets USING btree (tx_hash); -- -- Name: idx_expire; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_expire ON public.exhibitions USING btree (expire_at); -- -- Name: idx_fan_profiles_star_id; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_fan_profiles_star_id ON public.fan_profiles USING btree (star_id); -- -- Name: idx_fan_profiles_user_id; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_fan_profiles_user_id ON public.fan_profiles USING btree (user_id); -- -- Name: idx_friend_requests_expires; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_friend_requests_expires ON public.friend_requests USING btree (expires_at); -- -- Name: idx_friend_requests_from_status; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_friend_requests_from_status ON public.friend_requests USING btree (from_user_id, status, created_at DESC); -- -- Name: idx_friend_requests_star; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_friend_requests_star ON public.friend_requests USING btree (star_id); -- -- Name: idx_friend_requests_to_status; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_friend_requests_to_status ON public.friend_requests USING btree (to_user_id, status, created_at DESC); -- -- Name: idx_friend_requests_users_star; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_friend_requests_users_star ON public.friend_requests USING btree (from_user_id, to_user_id, star_id, created_at DESC); -- -- Name: idx_friendships_friend_star; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_friendships_friend_star ON public.friendships USING btree (friend_id); -- -- Name: idx_friendships_list_query; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_friendships_list_query ON public.friendships USING btree (user_id, friend_id, star_id, status, remark, created_at); -- -- Name: idx_friendships_user_star_created; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_friendships_user_star_created ON public.friendships USING btree (user_id, star_id, created_at DESC); -- -- Name: idx_friendships_user_star_status; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_friendships_user_star_status ON public.friendships USING btree (user_id, star_id, status); -- -- Name: idx_host; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_host ON public.exhibitions USING btree (host_profile_id); -- -- Name: idx_host_slot; Type: INDEX; Schema: public; Owner: - -- CREATE UNIQUE INDEX idx_host_slot ON public.booth_slots USING btree (host_profile_id, slot_index); -- -- Name: idx_mint_orders_asset; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_mint_orders_asset ON public.mint_orders USING btree (asset_id); -- -- Name: idx_mint_orders_created_at; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_mint_orders_created_at ON public.mint_orders USING btree (created_at DESC); -- -- Name: idx_mint_orders_status; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_mint_orders_status ON public.mint_orders USING btree (status); -- -- Name: idx_mint_orders_user_star; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_mint_orders_user_star ON public.mint_orders USING btree (user_id, star_id); -- -- Name: idx_occupier; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_occupier ON public.exhibitions USING btree (occupier_uid, occupier_star_id); -- -- Name: idx_slot; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_slot ON public.exhibitions USING btree (slot_id); -- -- Name: idx_star_enabled; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_star_enabled ON public.booth_slots USING btree (star_id); -- -- Name: idx_task_definitions_task_key; Type: INDEX; Schema: public; Owner: - -- CREATE UNIQUE INDEX idx_task_definitions_task_key ON public.task_definitions USING btree (task_key); -- -- Name: idx_user_revenue; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_user_revenue ON public.exhibition_revenue_records USING btree (user_id, star_id); -- -- Name: idx_user_star; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_user_star ON public.booth_slots USING btree (user_id, star_id); -- -- Name: idx_users_deleted_at; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX idx_users_deleted_at ON public.users USING btree (deleted_at); -- -- Name: uk_asset; Type: INDEX; Schema: public; Owner: - -- CREATE UNIQUE INDEX uk_asset ON public.exhibitions USING btree (asset_id); -- -- Name: uk_fan_profiles_star_nickname; Type: INDEX; Schema: public; Owner: - -- CREATE UNIQUE INDEX uk_fan_profiles_star_nickname ON public.fan_profiles USING btree (star_id, nickname); -- -- Name: uk_fan_profiles_user_star; Type: INDEX; Schema: public; Owner: - -- CREATE UNIQUE INDEX uk_fan_profiles_user_star ON public.fan_profiles USING btree (user_id, star_id); -- -- Name: uk_friendships_user_friend_star; Type: INDEX; Schema: public; Owner: - -- CREATE UNIQUE INDEX uk_friendships_user_friend_star ON public.friendships USING btree (user_id, friend_id, star_id); -- -- Name: uk_stars_identity_id; Type: INDEX; Schema: public; Owner: - -- CREATE UNIQUE INDEX uk_stars_identity_id ON public.stars USING btree (identity_id); -- -- Name: uk_user_star_onboarding; Type: INDEX; Schema: public; Owner: - -- CREATE UNIQUE INDEX uk_user_star_onboarding ON public.user_onboarding_status USING btree (user_id, star_id); -- -- Name: uk_user_task; Type: INDEX; Schema: public; Owner: - -- CREATE UNIQUE INDEX uk_user_task ON public.user_task_progress USING btree (user_id, star_id, task_key); -- -- Name: uk_users_mobile; Type: INDEX; Schema: public; Owner: - -- CREATE UNIQUE INDEX uk_users_mobile ON public.users USING btree (mobile); -- -- Name: activity_items fk_activities_items; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.activity_items ADD CONSTRAINT fk_activities_items FOREIGN KEY (activity_id) REFERENCES public.activities(id); -- -- Name: activity_contributions fk_activity_contributions_activity; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.activity_contributions ADD CONSTRAINT fk_activity_contributions_activity FOREIGN KEY (activity_id) REFERENCES public.activities(id) ON DELETE CASCADE; -- -- Name: activity_contributions fk_activity_contributions_item; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.activity_contributions ADD CONSTRAINT fk_activity_contributions_item FOREIGN KEY (item_id) REFERENCES public.activity_items(id) ON DELETE CASCADE; -- -- Name: activity_contributions fk_activity_contributions_star; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.activity_contributions ADD CONSTRAINT fk_activity_contributions_star FOREIGN KEY (star_id) REFERENCES public.stars(star_id) ON DELETE CASCADE; -- -- Name: activity_contributions fk_activity_contributions_user; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.activity_contributions ADD CONSTRAINT fk_activity_contributions_user FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: activity_items fk_activity_items_activity; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.activity_items ADD CONSTRAINT fk_activity_items_activity FOREIGN KEY (activity_id) REFERENCES public.activities(id) ON DELETE CASCADE; -- -- Name: activity_user_stats fk_activity_user_stats_activity; Type: FK CONSTRAINT; Schema: public; Owner: - -- 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; -- -- Name: activity_user_stats fk_activity_user_stats_star; Type: FK CONSTRAINT; Schema: public; Owner: - -- 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; -- -- Name: activity_user_stats fk_activity_user_stats_user; Type: FK CONSTRAINT; Schema: public; Owner: - -- 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; -- -- Name: asset_likes fk_asset_likes_asset; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.asset_likes ADD CONSTRAINT fk_asset_likes_asset FOREIGN KEY (asset_id) REFERENCES public.assets(id) ON DELETE CASCADE; -- -- Name: asset_likes fk_asset_likes_star; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.asset_likes ADD CONSTRAINT fk_asset_likes_star FOREIGN KEY (star_id) REFERENCES public.stars(star_id) ON DELETE CASCADE; -- -- Name: asset_likes fk_asset_likes_user; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.asset_likes ADD CONSTRAINT fk_asset_likes_user FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: asset_registry fk_registry_asset; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.asset_registry ADD CONSTRAINT fk_registry_asset FOREIGN KEY (asset_id) REFERENCES public.assets(id) ON DELETE CASCADE; -- -- Name: asset_registry fk_registry_owner; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.asset_registry ADD CONSTRAINT fk_registry_owner FOREIGN KEY (owner_uid) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: asset_registry fk_registry_star; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.asset_registry ADD CONSTRAINT fk_registry_star FOREIGN KEY (star_id) REFERENCES public.stars(star_id) ON DELETE CASCADE; -- -- Name: assets fk_assets_owner; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.assets ADD CONSTRAINT fk_assets_owner FOREIGN KEY (owner_uid) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: assets fk_assets_star; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.assets ADD CONSTRAINT fk_assets_star FOREIGN KEY (star_id) REFERENCES public.stars(star_id) ON DELETE CASCADE; -- -- Name: booth_slots fk_booth_slots_profile; Type: FK CONSTRAINT; Schema: public; Owner: - -- 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; -- -- Name: exhibitions fk_exhibitions_asset; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.exhibitions ADD CONSTRAINT fk_exhibitions_asset FOREIGN KEY (asset_id) REFERENCES public.assets(id) ON DELETE CASCADE; -- -- Name: exhibitions fk_exhibitions_slot; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.exhibitions ADD CONSTRAINT fk_exhibitions_slot FOREIGN KEY (slot_id) REFERENCES public.booth_slots(slot_id) ON DELETE CASCADE; -- -- Name: fan_profiles fk_fan_profiles_star; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.fan_profiles ADD CONSTRAINT fk_fan_profiles_star FOREIGN KEY (star_id) REFERENCES public.stars(star_id) ON DELETE CASCADE; -- -- Name: fan_profiles fk_fan_profiles_user; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.fan_profiles ADD CONSTRAINT fk_fan_profiles_user FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: friend_requests fk_friend_requests_from_user; Type: FK CONSTRAINT; Schema: public; Owner: - -- 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; -- -- Name: friend_requests fk_friend_requests_to_user; Type: FK CONSTRAINT; Schema: public; Owner: - -- 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; -- -- Name: friendships fk_friendships_friend; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.friendships ADD CONSTRAINT fk_friendships_friend FOREIGN KEY (friend_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: friendships fk_friendships_user; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.friendships ADD CONSTRAINT fk_friendships_user FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: mint_orders fk_mint_orders_asset; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.mint_orders ADD CONSTRAINT fk_mint_orders_asset FOREIGN KEY (asset_id) REFERENCES public.assets(id) ON DELETE SET NULL; -- -- Name: mint_orders fk_mint_orders_star; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.mint_orders ADD CONSTRAINT fk_mint_orders_star FOREIGN KEY (star_id) REFERENCES public.stars(star_id) ON DELETE CASCADE; -- -- Name: mint_orders fk_mint_orders_user; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.mint_orders ADD CONSTRAINT fk_mint_orders_user FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: fan_profiles fk_users_fan_profiles; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.fan_profiles ADD CONSTRAINT fk_users_fan_profiles FOREIGN KEY (user_id) REFERENCES public.users(id); -- -- PostgreSQL database dump complete -- \unrestrict sMtfDGEC88HGZIJke0nEBhyCFPngc2Pj7gKFCpH88m7WybaopqjS9o0UnzJwYTx -- ===================================================== -- V6: materials and asset_material_relations (2026-05-15) -- ===================================================== -- 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); -- 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; -- 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); -- 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) ); -- 插入铸爱阶梯数据 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; -- materials 外键 ALTER TABLE public.asset_material_relations ADD CONSTRAINT fk_amr_material FOREIGN KEY (material_id) REFERENCES public.materials(id) ON DELETE RESTRICT;