diff --git a/docker/.env.prod b/docker/.env.prod index 07667b3..8099fc4 100644 --- a/docker/.env.prod +++ b/docker/.env.prod @@ -13,10 +13,14 @@ JWT_SECRET=CHANGE_ME_TO_A_VERY_LONG_RANDOM_STRING # OSS Configuration OSS_REGION=cn-shanghai -OSS_BUCKET_NAME=top-fans-prod +OSS_BUCKET_NAME=top-fans-test OSS_STS_ROLE_ARN=acs:ram::1387642798143585:role/top-fans-oss-user -OSS_ACCESS_KEY_ID=LTAI5t6QcdJHpYbCPxM8SXYE -OSS_ACCESS_KEY_SECRET=ybvjSEb7wilMt3qT5nOppYPoNVayCD +OSS_ACCESS_KEY_ID=LTAI5t99tafzfyrzbbEbjryH +OSS_ACCESS_KEY_SECRET=sBmrqG9owzi53hiV4dpE3EL2A5dn9b OSS_AVATAR_DIR=avatar/ OSS_ASSET_DIR=asset/ OSS_TOKEN_EXPIRE_TIME=3600 + +# ==================== MiniMax API Configuration ==================== +MINIMAX_API_KEY=sk-cp-Fffv8Bg8zeFD929_KUAZq9EKet64Nkxgu7t1ibZEngqmyPKaOOa7U8U_gtg3VICfUQyGPn8c5XR4hxmWzjKC4wO6DxKh5ipN36Yv5jsFzZWMEPh6NKV2qAE +MINIMAX_API_URL=https://api.minimaxi.com/v1/image_generation diff --git a/docker/deploy.sh b/docker/deploy.sh index 2ed053b..04afe6c 100755 --- a/docker/deploy.sh +++ b/docker/deploy.sh @@ -5,28 +5,50 @@ # - 本地:构建镜像 → 推送到镜像仓库 # - 远程:拉取镜像 → 启动服务 # - 回滚:回滚到指定版本 +# - 配置:快速上传配置文件、重启服务 # =================================================================== # # 使用前提: # 1. 已安装 Docker # 2. 已创建阿里云容器镜像仓库 -# 3. 服务器已配置 SSH 免密登录(建议) +# 3. 服务器已配置 SSH 免密登录 # # 使用方式: -# # 本地构建 + 推送 +# # ========== 完整部署流程 ========== +# # 本地构建镜像 # ./deploy.sh build v1.0.0 # -# # 远程部署(从仓库拉取 + 启动) +# # 上传镜像到服务器(会自动跳过未变化的镜像) +# ./deploy.sh push v1.0.0 +# +# # 远程部署 # ./deploy.sh deploy v1.0.0 # +# # 一键构建 + 推送 + 部署 +# ./deploy.sh all v1.0.0 +# +# # ========== 配置更新(不重新构建镜像)========== +# # 修改 .env.prod 或 docker-compose.prod.yml 后: +# ./deploy.sh upload-config --server 101.132.250.62 +# +# # 上传配置并重启服务 +# ./deploy.sh upload-config --server 101.132.250.62 && ./deploy.sh restart --server 101.132.250.62 +# +# # ========== 其他命令 ========== # # 回滚到指定版本 -# ./deploy.sh rollback v1.0.0 +# ./deploy.sh rollback v0.9.0 # # # 查看部署历史 # ./deploy.sh history # -# # 一键构建 + 推送 + 部署(本地构建完成后远程部署) -# ./deploy.sh all v1.0.0 +# # 清理本地镜像 +# ./deploy.sh clean +# +# # ========== 服务器信息 ========== +# SERVER_HOST="101.132.250.62" +# SERVER_USER="root" +# SERVER_PASSWORD=">n73qBnCja-,#VF+Wq" +# SERVER_PATH="/opt/topfans/docker" # # =================================================================== @@ -61,8 +83,21 @@ SERVICES=( SERVER_HOST="101.132.250.62" # 服务器 IP 或域名 SERVER_PORT="22" # SSH 端口 SERVER_USER="root" # SSH 用户名 +SERVER_PASSWORD=">n73qBnCja-,#VF+Wq" # 服务器密码 SERVER_PATH="/opt/topfans/docker" # 服务器上 docker 目录路径 +# ==================== SSH 别名 ==================== +# 使用 sshpass 执行 SSH 命令 +ssh_cmd() { + sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p "$SERVER_PORT" "$SERVER_USER@$SERVER_HOST" "$@" +} +ssh_cmd_batch() { + sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no -p "$SERVER_PORT" "$SERVER_USER@$SERVER_HOST" "$@" +} +scp_cmd() { + sshpass -p "$SERVER_PASSWORD" scp -P "$SERVER_PORT" "$@" +} + # ==================== 打印函数 ==================== print_step() { echo "" @@ -92,6 +127,8 @@ ${YELLOW}命令:${NC} ${GREEN}history${NC} 查看部署历史 ${GREEN}all${NC} <版本号> 一键构建 + 传输 + 部署 ${GREEN}clean${NC} 清理本地镜像(谨慎使用) + ${GREEN}upload-config${NC} 仅上传配置文件(不重新构建镜像) + ${GREEN}restart${NC} 重启服务(不重新构建/上传) ${YELLOW}选项:${NC} --server 指定服务器(覆盖配置文件) @@ -106,6 +143,8 @@ ${YELLOW}示例:${NC} $0 rollback v0.9.0 # 回滚到 v0.9.0 $0 history # 查看部署历史 $0 all v1.0.0 --server 192.168.1.100 # 一键完成所有操作 + $0 upload-config --server 192.168.1.100 # 仅上传配置 + $0 restart --server 192.168.1.100 # 重启服务 ${YELLOW}前提准备:${NC} 1. 修改 SERVER_HOST 为你的服务器 IP @@ -182,21 +221,52 @@ do_push() { print_msg "$GREEN" "✅ 全部打包完成" + # 计算本地镜像的 MD5 哈希 + print_step "🔍 检查镜像差异" + local local_hash="" + for SERVICE in "${packed[@]}"; do + local tar_file="${tmp_dir}/${SERVICE}.tar" + local file_hash=$(md5 -q "${tar_file}") + local image_hash=$(docker images -q "topfans/${SERVICE}:latest") + local combo="${file_hash}:${image_hash}" + if [ -z "$local_hash" ]; then + local_hash="$combo" + else + local_hash="${local_hash}-${combo}" + fi + done + local local_md5=$(echo "$local_hash" | md5) + + print_msg "$YELLOW" "本地镜像 MD5: ${local_md5:0:16}..." + + # 获取服务器上的哈希 + local server_hash=$(ssh_cmd "cat ${SERVER_PATH}/images/.images_hash 2>/dev/null || echo ''") + print_step "📤 传输镜像到服务器" + # 检查是否需要上传 + if [ "$local_md5" = "$server_hash" ]; then + print_msg "$GREEN" "✅ 镜像未变化,跳过上传" + rm -rf "${tmp_dir}" + return 0 + fi + print_msg "$YELLOW" "正在传输到 ${SERVER_USER}@${SERVER_HOST}:${SERVER_PATH}..." # 创建服务器目录 - ssh -p "${SERVER_PORT}" "${SERVER_USER}@${SERVER_HOST}" "mkdir -p ${SERVER_PATH}/images && rm -f ${SERVER_PATH}/images/*.tar 2>/dev/null || true" + ssh_cmd "mkdir -p ${SERVER_PATH}/images && rm -f ${SERVER_PATH}/images/*.tar 2>/dev/null || true" # 传输 tar 文件 for SERVICE in "${packed[@]}"; do local tar_file="${tmp_dir}/${SERVICE}.tar" print_msg "$YELLOW" "传输 ${SERVICE}.tar..." - scp -P "${SERVER_PORT}" "${tar_file}" "${SERVER_USER}@${SERVER_HOST}:${SERVER_PATH}/images/" + scp_cmd "${tar_file}" "${SERVER_USER}@${SERVER_HOST}:${SERVER_PATH}/images/" print_msg "$GREEN" "✅ ${SERVICE}.tar 传输完成" done + # 保存哈希到服务器 + ssh_cmd "echo '$local_md5' > ${SERVER_PATH}/images/.images_hash" + # 清理本地临时文件 rm -rf "${tmp_dir}" @@ -217,40 +287,72 @@ do_deploy() { print_msg "$YELLOW" "检查 Docker 环境..." - ssh -p "${SERVER_PORT}" -T "${SERVER_USER}@${SERVER_HOST}" << 'ENDSSH' + sshpass -p "$SERVER_PASSWORD" ssh -T -p "${SERVER_PORT}" "${SERVER_USER}@${SERVER_HOST}" << 'ENDSSH' set -e -echo '=== 1. 检查 Docker 环境 ===' +echo '=== 1. 检查/安装 Docker 环境 ===' if ! command -v docker &> /dev/null; then - echo '❌ Docker 未安装' - exit 1 + echo '📦 Docker 未安装,开始安装...' + + # 使用阿里云镜像源安装 Docker + yum remove -y docker docker-common docker-selinux docker-engine-selinux docker-engine docker-ce 2>/dev/null || true + yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo + yum install -y docker-ce docker-ce-cli containerd.io + + systemctl start docker + systemctl enable docker + echo '✅ Docker 安装成功' fi -if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then - echo '❌ docker-compose 未安装' - exit 1 +if ! command -v docker-compose &> /dev/null; then + if docker compose version &> /dev/null; then + echo '📦 创建 docker-compose 软链接...' + ln -sf /usr/libexec/docker/cli-plugins/docker-compose /usr/local/bin/docker-compose + else + echo '⚠️ docker-compose 未安装' + fi fi +# 配置 Docker 镜像加速器 +echo '📦 配置 Docker 镜像加速器...' +mkdir -p /etc/docker +cat > /etc/docker/daemon.json << 'DOCKER_EOF' +{ + "registry-mirrors": [ + "https://docker.1ms.run", + "https://docker.xuanyuan.me" + ] +} +DOCKER_EOF +systemctl restart docker +echo '✅ 镜像加速器配置完成' + echo '✅ Docker 环境就绪' ENDSSH # 确保服务器目录存在 - ssh -p "${SERVER_PORT}" "${SERVER_USER}@${SERVER_HOST}" "mkdir -p ${SERVER_PATH}/images" + ssh_cmd "mkdir -p ${SERVER_PATH}/images" print_msg "$GREEN" "✅ 服务器目录就绪" + # 上传配置文件 + print_step "📤 上传配置文件" + print_msg "$YELLOW" "上传 docker-compose.prod.yml 和 .env.prod..." + scp_cmd "${SCRIPT_DIR}/docker-compose.prod.yml" "${SERVER_USER}@${SERVER_HOST}:${SERVER_PATH}/" + scp_cmd "${SCRIPT_DIR}/.env.prod" "${SERVER_USER}@${SERVER_HOST}:${SERVER_PATH}/" + scp_cmd "${SCRIPT_DIR}/init-db.sql" "${SERVER_USER}@${SERVER_HOST}:${SERVER_PATH}/" + print_msg "$GREEN" "✅ 配置文件上传完成" + # 从 tar 文件加载镜像 print_step "📥 从 tar 文件加载镜像" for SERVICE in "${SERVICES[@]}"; do print_msg "$YELLOW" "加载 ${SERVICE}..." - ssh -p "${SERVER_PORT}" "${SERVER_USER}@${SERVER_HOST}" " - docker load -i ${SERVER_PATH}/images/${SERVICE}.tar - " + ssh_cmd "docker load -i ${SERVER_PATH}/images/${SERVICE}.tar" print_msg "$GREEN" "✅ ${SERVICE} 加载完成" done # 打 latest 标签 print_msg "$YELLOW" "打 latest 标签..." - ssh -p "${SERVER_PORT}" "${SERVER_USER}@${SERVER_HOST}" " + ssh_cmd " for service in ${SERVICES[*]}; do docker tag topfans/\${service}:latest topfans/\${service}:v${version} docker tag topfans/\${service}:latest topfans/\${service}:latest @@ -258,27 +360,35 @@ ENDSSH echo '标签完成' " - # 停止旧服务 + # 停止旧服务并清理 print_msg "$YELLOW" "停止旧服务..." - ssh -p "${SERVER_PORT}" "${SERVER_USER}@${SERVER_HOST}" " + ssh_cmd " cd ${SERVER_PATH} && \ docker-compose -f docker-compose.prod.yml down 2>/dev/null || true + + # 停止并删除所有 topfans 容器 + docker ps -a --filter 'name=topfans-' -q | xargs -r docker stop 2>/dev/null || true + docker ps -a --filter 'name=topfans-' -q | xargs -r docker rm 2>/dev/null || true + + # 清理可能的端口占用 (8080, 5432) + fuser -k 8080/tcp 2>/dev/null || true + fuser -k 5432/tcp 2>/dev/null || true " # 启动新服务 print_msg "$YELLOW" "启动服务..." - ssh -p "${SERVER_PORT}" "${SERVER_USER}@${SERVER_HOST}" " + ssh_cmd " cd ${SERVER_PATH} && \ docker-compose -f docker-compose.prod.yml --profile prod up -d " # 等待并检查 - print_msg "$YELLOW" "等待服务启动 (15s)..." - sleep 15 + print_msg "$YELLOW" "等待服务启动 (20s)..." + sleep 20 print_step "📊 部署结果" - ssh -p "${SERVER_PORT}" "${SERVER_USER}@${SERVER_HOST}" " + ssh_cmd " echo '' docker-compose -f docker-compose.prod.yml ps echo '' @@ -304,7 +414,7 @@ do_rollback() { # 停止服务 print_msg "$YELLOW" "停止服务..." - ssh -p "${SERVER_PORT}" "${SERVER_USER}@${SERVER_HOST}" " + ssh_cmd " cd ${SERVER_PATH} && \ docker-compose -f docker-compose.prod.yml down " @@ -312,7 +422,7 @@ do_rollback() { # 从已有的 tar 文件加载镜像并打标签 for SERVICE in "${SERVICES[@]}"; do print_msg "$YELLOW" "加载 ${SERVICE}:v${version}..." - ssh -p "${SERVER_PORT}" "${SERVER_USER}@${SERVER_HOST}" " + ssh_cmd " docker load -i ${SERVER_PATH}/images/${SERVICE}.tar docker tag topfans/${SERVICE}:latest topfans/${SERVICE}:v${version} docker tag topfans/${SERVICE}:latest topfans/${SERVICE}:latest @@ -322,7 +432,7 @@ do_rollback() { # 启动服务 print_msg "$YELLOW" "启动服务..." - ssh -p "${SERVER_PORT}" "${SERVER_USER}@${SERVER_HOST}" " + ssh_cmd " cd ${SERVER_PATH} && \ docker-compose -f docker-compose.prod.yml --profile prod up -d " @@ -331,7 +441,7 @@ do_rollback() { print_step "📊 回滚结果" - ssh -p "${SERVER_PORT}" "${SERVER_USER}@${SERVER_HOST}" " + ssh_cmd " echo '' docker-compose -f docker-compose.prod.yml ps echo '' @@ -351,7 +461,7 @@ do_history() { print_step "📜 部署历史" - ssh -p "${SERVER_PORT}" "${SERVER_USER}@${SERVER_HOST}" " + ssh_cmd " if [ -f ${SERVER_PATH}/deploy_history.json ]; then cat ${SERVER_PATH}/deploy_history.json else @@ -492,6 +602,38 @@ main() { do_clean ;; + upload-config) + # 上传配置文件 + if [ -z "$SERVER_HOST" ]; then + print_msg "$RED" "错误: 请设置 SERVER_HOST 或使用 --server 参数" + exit 1 + fi + + print_step "📤 上传配置文件到 ${SERVER_HOST}" + + scp_cmd "${SCRIPT_DIR}/docker-compose.prod.yml" "${SERVER_USER}@${SERVER_HOST}:${SERVER_PATH}/" + print_msg "$GREEN" "✅ docker-compose.prod.yml 上传完成" + + scp_cmd "${SCRIPT_DIR}/.env.prod" "${SERVER_USER}@${SERVER_HOST}:${SERVER_PATH}/" + print_msg "$GREEN" "✅ .env.prod 上传完成" + + print_msg "$YELLOW" "请运行以下命令重启服务:" + print_msg "$CYAN" "ssh ${SERVER_USER}@${SERVER_HOST} 'cd ${SERVER_PATH} && docker-compose -f docker-compose.prod.yml down && docker-compose -f docker-compose.prod.yml up -d'" + ;; + + restart) + # 重启服务 + if [ -z "$SERVER_HOST" ]; then + print_msg "$RED" "错误: 请设置 SERVER_HOST 或使用 --server 参数" + exit 1 + fi + + print_step "🔄 重启服务" + ssh_cmd "cd ${SERVER_PATH} && docker-compose -f docker-compose.prod.yml down && docker-compose -f docker-compose.prod.yml up -d" + sleep 10 + print_msg "$GREEN" "✅ 服务重启完成" + ;; + all) # 构建 + 推送 + 部署 if [ -z "$version" ]; then diff --git a/docker/docker-compose.prod.yml b/docker/docker-compose.prod.yml index ed70b04..169f4e9 100644 --- a/docker/docker-compose.prod.yml +++ b/docker/docker-compose.prod.yml @@ -29,10 +29,10 @@ x-postgres-env: &postgres-env POSTGRES_WAL_BUFFERS: 8MB x-healthcheck: &healthcheck - interval: 15s + interval: 30s timeout: 10s - retries: 3 - start_period: 30s + retries: 5 + start_period: 60s services: # ==================== Database ==================== @@ -78,7 +78,7 @@ services: DB_NAME: topfans depends_on: postgres: - condition: service_healthy + condition: service_started networks: - topfans-net expose: @@ -111,7 +111,7 @@ services: DB_USER: postgres DB_PASSWORD: ${DB_PASSWORD:-postgres123} DB_NAME: topfans - DUBBO_USER_SERVICE_URL: tri://userservice:20000 + USER_SERVICE_URL: tri://userservice:20000 OSS_REGION: ${OSS_REGION:-cn-shanghai} OSS_BUCKET_NAME: ${OSS_BUCKET_NAME:-top-fans-test} OSS_STS_ROLE_ARN: ${OSS_STS_ROLE_ARN:-acs:ram::1387642798143585:role/top-fans-oss-user} @@ -122,7 +122,7 @@ services: OSS_TOKEN_EXPIRE_TIME: ${OSS_TOKEN_EXPIRE_TIME:-3600} depends_on: userservice: - condition: service_healthy + condition: service_started networks: - topfans-net expose: @@ -155,13 +155,13 @@ services: DB_USER: postgres DB_PASSWORD: ${DB_PASSWORD:-postgres123} DB_NAME: topfans - DUBBO_USER_SERVICE_URL: tri://userservice:20000 - DUBBO_ASSET_SERVICE_URL: tri://assetservice:20003 + USER_SERVICE_URL: tri://userservice:20000 + ASSET_SERVICE_URL: tri://assetservice:20003 depends_on: userservice: - condition: service_healthy + condition: service_started assetservice: - condition: service_healthy + condition: service_started networks: - topfans-net expose: @@ -194,13 +194,13 @@ services: DB_USER: postgres DB_PASSWORD: ${DB_PASSWORD:-postgres123} DB_NAME: topfans - DUBBO_USER_SERVICE_URL: tri://userservice:20000 - DUBBO_ASSET_SERVICE_URL: tri://assetservice:20003 + USER_SERVICE_URL: tri://userservice:20000 + ASSET_SERVICE_URL: tri://assetservice:20003 depends_on: userservice: - condition: service_healthy + condition: service_started assetservice: - condition: service_healthy + condition: service_started networks: - topfans-net expose: @@ -233,10 +233,10 @@ services: DB_USER: postgres DB_PASSWORD: ${DB_PASSWORD:-postgres123} DB_NAME: topfans - DUBBO_USER_SERVICE_URL: tri://userservice:20000 + USER_SERVICE_URL: tri://userservice:20000 depends_on: userservice: - condition: service_healthy + condition: service_started networks: - topfans-net expose: @@ -262,6 +262,8 @@ services: target: gateway container_name: topfans-gateway restart: always + env_file: + - .env.prod environment: <<: *common-env SERVER_PORT: 8080 @@ -273,15 +275,15 @@ services: DUBBO_ACTIVITY_SERVICE_URL: tri://activityservice:20005 depends_on: userservice: - condition: service_healthy + condition: service_started assetservice: - condition: service_healthy + condition: service_started socialservice: - condition: service_healthy + condition: service_started galleryservice: - condition: service_healthy + condition: service_started activityservice: - condition: service_healthy + condition: service_started networks: - topfans-net ports: @@ -298,40 +300,6 @@ services: memory: 64M cpus: '0.25' - # ==================== Admin Backend ==================== - admin-backend: - image: topfans/admin-backend:latest - build: - context: ../../TopFans-activity - dockerfile: docker/Dockerfile.admin - container_name: topfans-admin-backend - restart: always - environment: - <<: *common-env - DB_HOST: postgres - DB_PORT: 5432 - DB_USER: postgres - DB_PASSWORD: ${DB_PASSWORD:-postgres123} - DB_NAME: topfans - depends_on: - postgres: - condition: service_healthy - networks: - - topfans-net - ports: - - "8081:8081" - healthcheck: - test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:8081/health || exit 1"] - <<: *healthcheck - deploy: - resources: - limits: - memory: 200M - cpus: '0.5' - reservations: - memory: 64M - cpus: '0.25' - networks: topfans-net: driver: bridge diff --git a/docker/init-db.sql b/docker/init-db.sql index f153db0..4ca1f5b 100644 --- a/docker/init-db.sql +++ b/docker/init-db.sql @@ -1,401 +1,1749 @@ --- =================================================================== --- TopFans Database Initialization Script --- =================================================================== --- This script runs automatically when PostgreSQL container starts --- =================================================================== +-- +-- PostgreSQL database dump +-- --- TopFans 数据库初始化脚本 --- 创建所有表结构和索引 +\restrict NXfw4AHf53ndLJtQCalhae0Ymr5IJAi9umqWVq9QzKT09ZnpJXuxhwgGiRaJV9Y --- 开启扩展 -CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; +-- 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) --- ============================================ --- 1. stars 表 - 明星信息表 --- ============================================ -CREATE TABLE IF NOT EXISTS stars ( - star_id BIGSERIAL PRIMARY KEY, - name VARCHAR(100) NOT NULL, - tag VARCHAR(100), - name_en VARCHAR(100), - pic_url VARCHAR(500), - description TEXT, - identity_id VARCHAR(50) NOT NULL UNIQUE, - is_active BOOLEAN NOT NULL DEFAULT true, - created_at BIGINT NOT NULL, - updated_at BIGINT NOT NULL +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: postgres +-- + +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) ); --- ============================================ --- 2. users 表 - 用户表 --- ============================================ -CREATE TABLE IF NOT EXISTS users ( - id BIGSERIAL PRIMARY KEY, - mobile VARCHAR(11) NOT NULL UNIQUE, - password_hash VARCHAR(255) NOT NULL, - access_token TEXT, - token_expires_at BIGINT, - avatar_url VARCHAR(500), - global_wallet_address VARCHAR(100), - is_active BOOLEAN NOT NULL DEFAULT true, - created_at BIGINT NOT NULL, - updated_at BIGINT NOT NULL, - deleted_at BIGINT + +ALTER TABLE public.activities OWNER TO postgres; + +-- +-- Name: TABLE activities; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON TABLE public.activities IS '运营活动表'; + + +-- +-- Name: activities_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.activities_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER SEQUENCE public.activities_id_seq OWNER TO postgres; + +-- +-- Name: activities_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.activities_id_seq OWNED BY public.activities.id; + + +-- +-- Name: activity_contributions; Type: TABLE; Schema: public; Owner: postgres +-- + +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 INDEX IF NOT EXISTS idx_users_deleted_at ON users(deleted_at); --- ============================================ --- 3. fan_profiles 表 - 粉丝档案表 --- ============================================ -CREATE TABLE IF NOT EXISTS fan_profiles ( - id BIGSERIAL PRIMARY KEY, - user_id BIGINT NOT NULL, - star_id BIGINT NOT NULL, - nickname VARCHAR(50) NOT NULL, - level INTEGER NOT NULL DEFAULT 1, - times INTEGER NOT NULL DEFAULT 1, - social INTEGER NOT NULL DEFAULT 0, - experience BIGINT NOT NULL DEFAULT 0, - coin_balance BIGINT NOT NULL DEFAULT 0, - crystal_balance BIGINT NOT NULL DEFAULT 0, - tags JSONB, - avatar_url VARCHAR(500), - starbook_limit INTEGER NOT NULL DEFAULT 3, - slot_limit INTEGER NOT NULL DEFAULT 3, - assets_count INTEGER NOT NULL DEFAULT 0, - chain_address VARCHAR(100), - is_active BOOLEAN NOT NULL DEFAULT true, - created_at BIGINT NOT NULL, - updated_at BIGINT NOT NULL, +ALTER TABLE public.activity_contributions OWNER TO postgres; - CONSTRAINT uk_fan_profiles_user_star UNIQUE (user_id, star_id) +-- +-- Name: TABLE activity_contributions; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON TABLE public.activity_contributions IS '用户活动贡献记录表'; + + +-- +-- Name: activity_contributions_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.activity_contributions_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER SEQUENCE public.activity_contributions_id_seq OWNER TO postgres; + +-- +-- Name: activity_contributions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.activity_contributions_id_seq OWNED BY public.activity_contributions.id; + + +-- +-- Name: activity_items; Type: TABLE; Schema: public; Owner: postgres +-- + +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 UNIQUE INDEX IF NOT EXISTS uk_fan_profiles_star_nickname ON fan_profiles(star_id, nickname); -CREATE INDEX IF NOT EXISTS idx_fan_profiles_user_id ON fan_profiles(user_id); -CREATE INDEX IF NOT EXISTS idx_fan_profiles_star_id ON fan_profiles(star_id); -ALTER TABLE fan_profiles - ADD CONSTRAINT fk_fan_profiles_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, - ADD CONSTRAINT fk_fan_profiles_star FOREIGN KEY (star_id) REFERENCES stars(star_id) ON DELETE CASCADE; +ALTER TABLE public.activity_items OWNER TO postgres; --- ============================================ --- 4. assets 表 - 资产表(藏品) --- ============================================ -CREATE TABLE IF NOT EXISTS assets ( - id BIGSERIAL PRIMARY KEY, - owner_uid BIGINT NOT NULL, - star_id BIGINT NOT NULL, - name VARCHAR(100) NOT NULL, - cover_url VARCHAR(500) NOT NULL, - material_url VARCHAR(500), - description TEXT, - rarity INTEGER, - tags JSONB, - visibility VARCHAR(20) NOT NULL DEFAULT 'private', - status INTEGER NOT NULL DEFAULT 0, - tx_hash VARCHAR(100), - block_number BIGINT, - like_count INTEGER NOT NULL DEFAULT 0, - is_original BOOLEAN NOT NULL DEFAULT false, - created_at BIGINT NOT NULL, - updated_at BIGINT NOT NULL, - minted_at BIGINT, - deleted_at BIGINT, - is_active BOOLEAN NOT NULL DEFAULT true +-- +-- Name: TABLE activity_items; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON TABLE public.activity_items IS '活动道具表'; + + +-- +-- Name: activity_items_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.activity_items_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER SEQUENCE public.activity_items_id_seq OWNER TO postgres; + +-- +-- Name: activity_items_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.activity_items_id_seq OWNED BY public.activity_items.id; + + +-- +-- Name: activity_user_stats; Type: TABLE; Schema: public; Owner: postgres +-- + +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 INDEX IF NOT EXISTS idx_assets_owner_star ON assets(owner_uid, star_id); -CREATE INDEX IF NOT EXISTS idx_assets_star_active ON assets(star_id, is_active); -CREATE INDEX IF NOT EXISTS idx_assets_status ON assets(status); -CREATE INDEX IF NOT EXISTS idx_assets_tx_hash ON assets(tx_hash); -CREATE INDEX IF NOT EXISTS idx_assets_created_at ON assets(created_at DESC); -CREATE INDEX IF NOT EXISTS idx_assets_deleted_at ON assets(deleted_at); -ALTER TABLE assets - ADD CONSTRAINT fk_assets_owner FOREIGN KEY (owner_uid) REFERENCES users(id) ON DELETE CASCADE, - ADD CONSTRAINT fk_assets_star FOREIGN KEY (star_id) REFERENCES stars(star_id) ON DELETE CASCADE; +ALTER TABLE public.activity_user_stats OWNER TO postgres; --- ============================================ --- 5. mint_orders 表 - 铸造订单表 --- ============================================ -CREATE TABLE IF NOT EXISTS mint_orders ( - order_id VARCHAR(100) PRIMARY KEY, - user_id BIGINT NOT NULL, - asset_id BIGINT, - star_id BIGINT NOT NULL, - status VARCHAR(20) NOT NULL DEFAULT 'PENDING', - cost_crystal BIGINT DEFAULT 0, - error_message TEXT, - retry_count INTEGER DEFAULT 0, - material_url VARCHAR(500), - name VARCHAR(100), - description TEXT, - material_type VARCHAR(50), - event VARCHAR(100), - created_at BIGINT NOT NULL, - updated_at BIGINT NOT NULL, - minted_at BIGINT +-- +-- Name: TABLE activity_user_stats; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON TABLE public.activity_user_stats IS '用户活动贡献汇总表'; + + +-- +-- Name: activity_user_stats_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.activity_user_stats_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER SEQUENCE public.activity_user_stats_id_seq OWNER TO postgres; + +-- +-- Name: activity_user_stats_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.activity_user_stats_id_seq OWNED BY public.activity_user_stats.id; + + +-- +-- Name: asset_likes; Type: TABLE; Schema: public; Owner: postgres +-- + +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 INDEX IF NOT EXISTS idx_mint_orders_user_star ON mint_orders(user_id, star_id); -CREATE INDEX IF NOT EXISTS idx_mint_orders_asset ON mint_orders(asset_id); -CREATE INDEX IF NOT EXISTS idx_mint_orders_status ON mint_orders(status); -CREATE INDEX IF NOT EXISTS idx_mint_orders_created_at ON mint_orders(created_at DESC); -ALTER TABLE mint_orders - ADD CONSTRAINT fk_mint_orders_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, - ADD CONSTRAINT fk_mint_orders_asset FOREIGN KEY (asset_id) REFERENCES assets(id) ON DELETE SET NULL, - ADD CONSTRAINT fk_mint_orders_star FOREIGN KEY (star_id) REFERENCES stars(star_id) ON DELETE CASCADE; +ALTER TABLE public.asset_likes OWNER TO postgres; --- ============================================ --- 6. asset_likes 表 - 点赞记录表 --- ============================================ -CREATE TABLE IF NOT EXISTS asset_likes ( - id BIGSERIAL PRIMARY KEY, - 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: postgres +-- - CONSTRAINT uk_asset_likes_user_asset UNIQUE (user_id, asset_id) +COMMENT ON TABLE public.asset_likes IS '点赞记录表'; + + +-- +-- Name: asset_likes_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.asset_likes_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER SEQUENCE public.asset_likes_id_seq OWNER TO postgres; + +-- +-- Name: asset_likes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.asset_likes_id_seq OWNED BY public.asset_likes.id; + + +-- +-- Name: assets; Type: TABLE; Schema: public; Owner: postgres +-- + +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 ); -CREATE INDEX IF NOT EXISTS idx_asset_likes_asset ON asset_likes(asset_id); -CREATE INDEX IF NOT EXISTS idx_asset_likes_user_star ON asset_likes(user_id, star_id); -ALTER TABLE asset_likes - ADD CONSTRAINT fk_asset_likes_asset FOREIGN KEY (asset_id) REFERENCES assets(id) ON DELETE CASCADE, - ADD CONSTRAINT fk_asset_likes_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, - ADD CONSTRAINT fk_asset_likes_star FOREIGN KEY (star_id) REFERENCES stars(star_id) ON DELETE CASCADE; +ALTER TABLE public.assets OWNER TO postgres; --- ============================================ --- 7. friendships 表 - 好友关系表 --- ============================================ -CREATE TABLE IF NOT EXISTS friendships ( - id BIGSERIAL PRIMARY KEY, - user_id BIGINT NOT NULL, - friend_id BIGINT NOT NULL, - star_id BIGINT NOT NULL, - status VARCHAR(20) NOT NULL DEFAULT 'accepted', - remark VARCHAR(50), - intimacy INTEGER NOT NULL DEFAULT 0, - created_at BIGINT NOT NULL, - updated_at BIGINT NOT NULL, +-- +-- Name: TABLE assets; Type: COMMENT; Schema: public; Owner: postgres +-- - CONSTRAINT uk_friendships_user_friend_star UNIQUE (user_id, friend_id, star_id) +COMMENT ON TABLE public.assets IS '资产表(藏品)'; + + +-- +-- Name: assets_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.assets_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER SEQUENCE public.assets_id_seq OWNER TO postgres; + +-- +-- Name: assets_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.assets_id_seq OWNED BY public.assets.id; + + +-- +-- Name: booth_slots; Type: TABLE; Schema: public; Owner: postgres +-- + +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 INDEX IF NOT EXISTS idx_friendships_user_star_status ON friendships(user_id, star_id, status); -CREATE INDEX IF NOT EXISTS idx_friendships_user_star_created ON friendships(user_id, star_id, created_at DESC); -CREATE INDEX IF NOT EXISTS idx_friendships_friend_star ON friendships(friend_id, star_id); -CREATE INDEX IF NOT EXISTS idx_friendships_list_query ON friendships(user_id, star_id, status, created_at DESC); -ALTER TABLE friendships - ADD CONSTRAINT fk_friendships_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, - ADD CONSTRAINT fk_friendships_friend FOREIGN KEY (friend_id) REFERENCES users(id) ON DELETE CASCADE, - ADD CONSTRAINT fk_friendships_star FOREIGN KEY (star_id) REFERENCES stars(star_id) ON DELETE CASCADE; +ALTER TABLE public.booth_slots OWNER TO postgres; --- ============================================ --- 8. friend_requests 表 - 好友请求表 --- ============================================ -CREATE TABLE IF NOT EXISTS friend_requests ( - id BIGSERIAL PRIMARY KEY, - from_user_id BIGINT NOT NULL, - to_user_id BIGINT NOT NULL, - star_id BIGINT NOT NULL, - message VARCHAR(200), - status VARCHAR(20) NOT NULL DEFAULT 'pending', - created_at BIGINT NOT NULL, - updated_at BIGINT NOT NULL, - expires_at BIGINT, - processed_at BIGINT +-- +-- Name: TABLE booth_slots; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON TABLE public.booth_slots IS '展位表'; + + +-- +-- Name: booth_slots_slot_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.booth_slots_slot_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER SEQUENCE public.booth_slots_slot_id_seq OWNER TO postgres; + +-- +-- Name: booth_slots_slot_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.booth_slots_slot_id_seq OWNED BY public.booth_slots.slot_id; + + +-- +-- Name: exhibition_revenue_records; Type: TABLE; Schema: public; Owner: postgres +-- + +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 INDEX IF NOT EXISTS idx_friend_requests_from_status ON friend_requests(from_user_id, status); -CREATE INDEX IF NOT EXISTS idx_friend_requests_to_status ON friend_requests(to_user_id, status); -CREATE INDEX IF NOT EXISTS idx_friend_requests_star ON friend_requests(star_id); -CREATE INDEX IF NOT EXISTS idx_friend_requests_users_star ON friend_requests(from_user_id, to_user_id, star_id); -CREATE INDEX IF NOT EXISTS idx_friend_requests_expires ON friend_requests(expires_at); -ALTER TABLE friend_requests - ADD CONSTRAINT fk_friend_requests_from_user FOREIGN KEY (from_user_id) REFERENCES users(id) ON DELETE CASCADE, - ADD CONSTRAINT fk_friend_requests_to_user FOREIGN KEY (to_user_id) REFERENCES users(id) ON DELETE CASCADE, - ADD CONSTRAINT fk_friend_requests_star FOREIGN KEY (star_id) REFERENCES stars(star_id) ON DELETE CASCADE; +ALTER TABLE public.exhibition_revenue_records OWNER TO postgres; --- ============================================ --- 9. booth_slots 表 - 展位表 --- ============================================ -CREATE TABLE IF NOT EXISTS booth_slots ( - slot_id BIGSERIAL PRIMARY KEY, - host_profile_id BIGINT NOT NULL, - user_id BIGINT NOT NULL, - star_id BIGINT NOT NULL, - slot_index INTEGER NOT NULL, - visibility VARCHAR(20) NOT NULL DEFAULT 'public', - is_enabled BOOLEAN DEFAULT false, - unlock_type VARCHAR(20), - unlock_value INTEGER, - created_at BIGINT NOT NULL, - updated_at BIGINT NOT NULL, +-- +-- Name: exhibition_revenue_records_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- - CONSTRAINT uk_host_slot UNIQUE (host_profile_id, slot_index) +CREATE SEQUENCE public.exhibition_revenue_records_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER SEQUENCE public.exhibition_revenue_records_id_seq OWNER TO postgres; + +-- +-- Name: exhibition_revenue_records_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.exhibition_revenue_records_id_seq OWNED BY public.exhibition_revenue_records.id; + + +-- +-- Name: exhibitions; Type: TABLE; Schema: public; Owner: postgres +-- + +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 ); -CREATE INDEX IF NOT EXISTS idx_user_star ON booth_slots(user_id, star_id); -CREATE INDEX IF NOT EXISTS idx_star_enabled ON booth_slots(star_id, is_enabled); -ALTER TABLE booth_slots - ADD CONSTRAINT fk_booth_slots_profile FOREIGN KEY (host_profile_id) REFERENCES fan_profiles(id) ON DELETE CASCADE; +ALTER TABLE public.exhibitions OWNER TO postgres; --- ============================================ --- 10. exhibitions 表 - 展品展示表 --- ============================================ -CREATE TABLE IF NOT EXISTS exhibitions ( - id BIGSERIAL PRIMARY KEY, - 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, +-- +-- Name: TABLE exhibitions; Type: COMMENT; Schema: public; Owner: postgres +-- - CONSTRAINT uk_asset UNIQUE (asset_id) +COMMENT ON TABLE public.exhibitions IS '展品展示表'; + + +-- +-- Name: exhibitions_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.exhibitions_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER SEQUENCE public.exhibitions_id_seq OWNER TO postgres; + +-- +-- Name: exhibitions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.exhibitions_id_seq OWNED BY public.exhibitions.id; + + +-- +-- Name: fan_profiles; Type: TABLE; Schema: public; Owner: postgres +-- + +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 INDEX IF NOT EXISTS idx_slot ON exhibitions(slot_id); -CREATE INDEX IF NOT EXISTS idx_host ON exhibitions(host_profile_id); -CREATE INDEX IF NOT EXISTS idx_occupier ON exhibitions(occupier_uid, occupier_star_id); -CREATE INDEX IF NOT EXISTS idx_expire ON exhibitions(expire_at); -ALTER TABLE exhibitions - ADD CONSTRAINT fk_exhibitions_asset FOREIGN KEY (asset_id) REFERENCES assets(id) ON DELETE CASCADE, - ADD CONSTRAINT fk_exhibitions_slot FOREIGN KEY (slot_id) REFERENCES booth_slots(slot_id) ON DELETE CASCADE; +ALTER TABLE public.fan_profiles OWNER TO postgres; --- ============================================ --- 11. activities 表 - 运营活动表 --- ============================================ -CREATE TABLE IF NOT EXISTS activities ( - id BIGSERIAL PRIMARY KEY, - activity_type VARCHAR(50) NOT NULL, - title VARCHAR(100) NOT NULL, - description TEXT, - star_id BIGINT NOT NULL, - start_time BIGINT NOT NULL, - end_time BIGINT NOT NULL, - target_progress BIGINT NOT NULL DEFAULT 1000, - current_progress BIGINT NOT NULL DEFAULT 0, - status VARCHAR(20) NOT NULL DEFAULT 'pending', - stage_configs JSONB, - created_at BIGINT NOT NULL, - updated_at BIGINT NOT NULL +-- +-- Name: TABLE fan_profiles; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON TABLE public.fan_profiles IS '粉丝档案表'; + + +-- +-- Name: fan_profiles_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.fan_profiles_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER SEQUENCE public.fan_profiles_id_seq OWNER TO postgres; + +-- +-- Name: fan_profiles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.fan_profiles_id_seq OWNED BY public.fan_profiles.id; + + +-- +-- Name: friend_requests; Type: TABLE; Schema: public; Owner: postgres +-- + +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 INDEX IF NOT EXISTS idx_activities_star_id ON activities(star_id); -CREATE INDEX IF NOT EXISTS idx_activities_status ON activities(status); -CREATE INDEX IF NOT EXISTS idx_activities_start_end ON activities(start_time, end_time); --- ============================================ --- 12. activity_items 表 - 活动道具表 --- ============================================ -CREATE TABLE IF NOT EXISTS activity_items ( - id BIGSERIAL PRIMARY KEY, - activity_id BIGINT NOT NULL, - item_type VARCHAR(50) NOT NULL, - item_name VARCHAR(50) NOT NULL, - icon_url VARCHAR(500), - crystal_cost INTEGER NOT NULL, - contribution_points INTEGER NOT NULL, - sort_order INTEGER NOT NULL DEFAULT 0, - is_active BOOLEAN NOT NULL DEFAULT true, - created_at BIGINT NOT NULL, - updated_at BIGINT NOT NULL +ALTER TABLE public.friend_requests OWNER TO postgres; + +-- +-- Name: TABLE friend_requests; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON TABLE public.friend_requests IS '好友请求表'; + + +-- +-- Name: friend_requests_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.friend_requests_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER SEQUENCE public.friend_requests_id_seq OWNER TO postgres; + +-- +-- Name: friend_requests_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.friend_requests_id_seq OWNED BY public.friend_requests.id; + + +-- +-- Name: friendships; Type: TABLE; Schema: public; Owner: postgres +-- + +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 INDEX IF NOT EXISTS idx_activity_items_activity ON activity_items(activity_id); -CREATE INDEX IF NOT EXISTS idx_activity_items_type ON activity_items(item_type); --- ============================================ --- 13. activity_contributions 表 - 用户活动贡献记录表 --- ============================================ -CREATE TABLE IF NOT EXISTS activity_contributions ( - id BIGSERIAL PRIMARY KEY, - activity_id BIGINT NOT NULL, - user_id BIGINT NOT NULL, - star_id BIGINT NOT NULL, - item_id BIGINT NOT NULL, - item_type VARCHAR(50) NOT NULL, - quantity INTEGER NOT NULL DEFAULT 1, - crystal_spent BIGINT NOT NULL, - contribution_points BIGINT NOT NULL, - created_at BIGINT NOT NULL +ALTER TABLE public.friendships OWNER TO postgres; + +-- +-- Name: TABLE friendships; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON TABLE public.friendships IS '好友关系表'; + + +-- +-- Name: friendships_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.friendships_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER SEQUENCE public.friendships_id_seq OWNER TO postgres; + +-- +-- Name: friendships_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.friendships_id_seq OWNED BY public.friendships.id; + + +-- +-- Name: mint_orders; Type: TABLE; Schema: public; Owner: postgres +-- + +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 ); -CREATE INDEX IF NOT EXISTS idx_activity_contributions_activity ON activity_contributions(activity_id); -CREATE INDEX IF NOT EXISTS idx_activity_contributions_user_star ON activity_contributions(user_id, star_id); -CREATE INDEX IF NOT EXISTS idx_activity_contributions_created ON activity_contributions(created_at DESC); --- ============================================ --- 14. activity_user_stats 表 - 用户活动贡献汇总表 --- ============================================ -CREATE TABLE IF NOT EXISTS activity_user_stats ( - id BIGSERIAL PRIMARY KEY, - activity_id BIGINT NOT NULL, - user_id BIGINT NOT NULL, - star_id BIGINT NOT NULL, - total_contribution BIGINT NOT NULL DEFAULT 0, - total_crystal_spent BIGINT NOT NULL DEFAULT 0, - total_items INTEGER NOT NULL DEFAULT 0, - last_contribute_at BIGINT NOT NULL, - created_at BIGINT NOT NULL, - updated_at BIGINT NOT NULL, +ALTER TABLE public.mint_orders OWNER TO postgres; - CONSTRAINT uk_activity_user_star UNIQUE (activity_id, user_id, star_id) +-- +-- Name: TABLE mint_orders; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON TABLE public.mint_orders IS '铸造订单表'; + + +-- +-- Name: stars; Type: TABLE; Schema: public; Owner: postgres +-- + +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 INDEX IF NOT EXISTS idx_activity_user_stats_activity ON activity_user_stats(activity_id); -CREATE INDEX IF NOT EXISTS idx_activity_user_stats_contribution ON activity_user_stats(activity_id, total_contribution DESC); -CREATE INDEX IF NOT EXISTS idx_activity_user_stats_user_star ON activity_user_stats(user_id, star_id); --- ============================================ --- 外键约束 - Activity Tables --- ============================================ -ALTER TABLE activity_items - ADD CONSTRAINT fk_activity_items_activity FOREIGN KEY (activity_id) REFERENCES activities(id) ON DELETE CASCADE; +ALTER TABLE public.stars OWNER TO postgres; -ALTER TABLE activity_contributions - ADD CONSTRAINT fk_activity_contributions_activity FOREIGN KEY (activity_id) REFERENCES activities(id) ON DELETE CASCADE, - ADD CONSTRAINT fk_activity_contributions_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, - ADD CONSTRAINT fk_activity_contributions_item FOREIGN KEY (item_id) REFERENCES activity_items(id) ON DELETE CASCADE, - ADD CONSTRAINT fk_activity_contributions_star FOREIGN KEY (star_id) REFERENCES stars(star_id) ON DELETE CASCADE; +-- +-- Name: TABLE stars; Type: COMMENT; Schema: public; Owner: postgres +-- -ALTER TABLE activity_user_stats - ADD CONSTRAINT fk_activity_user_stats_activity FOREIGN KEY (activity_id) REFERENCES activities(id) ON DELETE CASCADE, - ADD CONSTRAINT fk_activity_user_stats_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, - ADD CONSTRAINT fk_activity_user_stats_star FOREIGN KEY (star_id) REFERENCES stars(star_id) ON DELETE CASCADE; +COMMENT ON TABLE public.stars IS '明星信息表'; --- ============================================ --- 注释说明 --- ============================================ -COMMENT ON TABLE stars IS '明星信息表'; -COMMENT ON TABLE users IS '用户表'; -COMMENT ON TABLE fan_profiles IS '粉丝档案表'; -COMMENT ON TABLE assets IS '资产表(藏品)'; -COMMENT ON TABLE mint_orders IS '铸造订单表'; -COMMENT ON TABLE asset_likes IS '点赞记录表'; -COMMENT ON TABLE friendships IS '好友关系表'; -COMMENT ON TABLE friend_requests IS '好友请求表'; -COMMENT ON TABLE booth_slots IS '展位表'; -COMMENT ON TABLE exhibitions IS '展品展示表'; -COMMENT ON TABLE activities IS '运营活动表'; -COMMENT ON TABLE activity_items IS '活动道具表'; -COMMENT ON TABLE activity_contributions IS '用户活动贡献记录表'; -COMMENT ON TABLE activity_user_stats IS '用户活动贡献汇总表'; --- =================================================================== --- Initialization Complete --- =================================================================== +-- +-- Name: stars_star_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.stars_star_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER SEQUENCE public.stars_star_id_seq OWNER TO postgres; + +-- +-- Name: stars_star_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.stars_star_id_seq OWNED BY public.stars.star_id; + + +-- +-- Name: task_definitions; Type: TABLE; Schema: public; Owner: postgres +-- + +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 +); + + +ALTER TABLE public.task_definitions OWNER TO postgres; + +-- +-- Name: task_definitions_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.task_definitions_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER SEQUENCE public.task_definitions_id_seq OWNER TO postgres; + +-- +-- Name: task_definitions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.task_definitions_id_seq OWNED BY public.task_definitions.id; + + +-- +-- Name: user_onboarding_status; Type: TABLE; Schema: public; Owner: postgres +-- + +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 +); + + +ALTER TABLE public.user_onboarding_status OWNER TO postgres; + +-- +-- Name: user_onboarding_status_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.user_onboarding_status_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER SEQUENCE public.user_onboarding_status_id_seq OWNER TO postgres; + +-- +-- Name: user_onboarding_status_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.user_onboarding_status_id_seq OWNED BY public.user_onboarding_status.id; + + +-- +-- Name: user_task_progress; Type: TABLE; Schema: public; Owner: postgres +-- + +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 +); + + +ALTER TABLE public.user_task_progress OWNER TO postgres; + +-- +-- Name: user_task_progress_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.user_task_progress_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER SEQUENCE public.user_task_progress_id_seq OWNER TO postgres; + +-- +-- Name: user_task_progress_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.user_task_progress_id_seq OWNED BY public.user_task_progress.id; + + +-- +-- Name: users; Type: TABLE; Schema: public; Owner: postgres +-- + +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 +); + + +ALTER TABLE public.users OWNER TO postgres; + +-- +-- Name: TABLE users; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON TABLE public.users IS '用户表'; + + +-- +-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.users_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER SEQUENCE public.users_id_seq OWNER TO postgres; + +-- +-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id; + + +-- +-- Name: activities id; Type: DEFAULT; Schema: public; Owner: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +ALTER TABLE ONLY public.asset_likes ALTER COLUMN id SET DEFAULT nextval('public.asset_likes_id_seq'::regclass); + + +-- +-- Name: assets id; Type: DEFAULT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.assets ALTER COLUMN id SET DEFAULT nextval('public.assets_id_seq'::regclass); + + +-- +-- Name: booth_slots slot_id; Type: DEFAULT; Schema: public; Owner: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +ALTER TABLE ONLY public.activities + ADD CONSTRAINT activities_pkey PRIMARY KEY (id); + + +-- +-- Name: activity_contributions activity_contributions_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +ALTER TABLE ONLY public.asset_likes + ADD CONSTRAINT asset_likes_pkey PRIMARY KEY (id); + + +-- +-- Name: assets assets_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.assets + ADD CONSTRAINT assets_pkey PRIMARY KEY (id); + + +-- +-- Name: booth_slots booth_slots_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +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: postgres +-- + +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: postgres +-- + +ALTER TABLE ONLY public.exhibitions + ADD CONSTRAINT exhibitions_pkey PRIMARY KEY (id); + + +-- +-- Name: fan_profiles fan_profiles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +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: postgres +-- + +ALTER TABLE ONLY public.friend_requests + ADD CONSTRAINT friend_requests_pkey PRIMARY KEY (id); + + +-- +-- Name: friendships friendships_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.friendships + ADD CONSTRAINT friendships_pkey PRIMARY KEY (id); + + +-- +-- Name: mint_orders mint_orders_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.mint_orders + ADD CONSTRAINT mint_orders_pkey PRIMARY KEY (order_id); + + +-- +-- Name: stars stars_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.stars + ADD CONSTRAINT stars_pkey PRIMARY KEY (star_id); + + +-- +-- Name: task_definitions task_definitions_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +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: postgres +-- + +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; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.asset_likes + ADD CONSTRAINT uk_asset_likes_user_asset UNIQUE (user_id, asset_id); + + +-- +-- Name: user_onboarding_status user_onboarding_status_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +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: postgres +-- + +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: postgres +-- + +ALTER TABLE ONLY public.users + ADD CONSTRAINT users_pkey PRIMARY KEY (id); + + +-- +-- Name: idx_activities_star_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_activities_star_id ON public.activities USING btree (star_id); + + +-- +-- Name: idx_activities_start_end; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_activities_start_end ON public.activities USING btree (start_time, end_time); + + +-- +-- Name: idx_activities_status; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_activities_status ON public.activities USING btree (status); + + +-- +-- Name: idx_activity_contributions_activity; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_activity_contributions_activity ON public.activity_contributions USING btree (activity_id); + + +-- +-- Name: idx_activity_contributions_created; Type: INDEX; Schema: public; Owner: postgres +-- + +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: postgres +-- + +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: postgres +-- + +CREATE INDEX idx_activity_items_activity ON public.activity_items USING btree (activity_id); + + +-- +-- Name: idx_activity_items_type; Type: INDEX; Schema: public; Owner: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +CREATE INDEX idx_asset_likes_user_star ON public.asset_likes USING btree (user_id, star_id); + + +-- +-- Name: idx_assets_created_at; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_assets_created_at ON public.assets USING btree (created_at DESC); + + +-- +-- Name: idx_assets_deleted_at; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_assets_deleted_at ON public.assets USING btree (deleted_at); + + +-- +-- Name: idx_assets_owner_star; Type: INDEX; Schema: public; Owner: postgres +-- + +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: postgres +-- + +CREATE INDEX idx_assets_star_active ON public.assets USING btree (star_id, is_active); + + +-- +-- Name: idx_assets_status; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_assets_status ON public.assets USING btree (status); + + +-- +-- Name: idx_assets_tx_hash; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_assets_tx_hash ON public.assets USING btree (tx_hash); + + +-- +-- Name: idx_expire; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_expire ON public.exhibitions USING btree (expire_at); + + +-- +-- Name: idx_fan_profiles_star_id; Type: INDEX; Schema: public; Owner: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +CREATE INDEX idx_friendships_friend_star ON public.friendships USING btree (friend_id); + + +-- +-- Name: idx_friendships_list_query; Type: INDEX; Schema: public; Owner: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +CREATE INDEX idx_host ON public.exhibitions USING btree (host_profile_id); + + +-- +-- Name: idx_host_slot; Type: INDEX; Schema: public; Owner: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +CREATE INDEX idx_mint_orders_status ON public.mint_orders USING btree (status); + + +-- +-- Name: idx_mint_orders_user_star; Type: INDEX; Schema: public; Owner: postgres +-- + +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: postgres +-- + +CREATE INDEX idx_occupier ON public.exhibitions USING btree (occupier_uid, occupier_star_id); + + +-- +-- Name: idx_slot; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_slot ON public.exhibitions USING btree (slot_id); + + +-- +-- Name: idx_star_enabled; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_star_enabled ON public.booth_slots USING btree (star_id); + + +-- +-- Name: idx_task_definitions_task_key; Type: INDEX; Schema: public; Owner: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +CREATE INDEX idx_users_deleted_at ON public.users USING btree (deleted_at); + + +-- +-- Name: uk_asset; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX uk_asset ON public.exhibitions USING btree (asset_id); + + +-- +-- Name: uk_fan_profiles_star_nickname; Type: INDEX; Schema: public; Owner: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +CREATE UNIQUE INDEX uk_stars_identity_id ON public.stars USING btree (identity_id); + + +-- +-- Name: uk_user_star_onboarding; Type: INDEX; Schema: public; Owner: postgres +-- + +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: postgres +-- + +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: postgres +-- + +CREATE UNIQUE INDEX uk_users_mobile ON public.users USING btree (mobile); + + +-- +-- Name: activity_items fk_activities_items; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +ALTER TABLE ONLY public.asset_likes + ADD CONSTRAINT fk_asset_likes_user FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; + + +-- +-- Name: assets fk_assets_owner; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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: postgres +-- + +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 NXfw4AHf53ndLJtQCalhae0Ymr5IJAi9umqWVq9QzKT09ZnpJXuxhwgGiRaJV9Y + diff --git a/docker/快速配置更新指南.md b/docker/快速配置更新指南.md new file mode 100644 index 0000000..ffce110 --- /dev/null +++ b/docker/快速配置更新指南.md @@ -0,0 +1,73 @@ +# 快速配置更新指南 + +## 场景:只修改了配置,不想重新推送镜像 + +### 1. 更新配置文件到服务器 + +```bash +cd /Users/liulujian/Documents/code/TopFansByGithub/docker + +# 上传 .env.prod +sshpass -p '>n73qBnCja-,#VF+Wq' scp -P 22 .env.prod root@101.132.250.62:/opt/topfans/docker/ + +# 上传 docker-compose.prod.yml(如果也修改了) +sshpass -p '>n73qBnCja-,#VF+Wq' scp -P 22 docker-compose.prod.yml root@101.132.250.62:/opt/topfans/docker/ +``` + +### 2. 重启服务 + +```bash +sshpass -p '>n73qBnCja-,#VF+Wq' ssh -o StrictHostKeyChecking=no -p 22 root@101.132.250.62 ' +cd /opt/topfans/docker +docker-compose -f docker-compose.prod.yml down +docker-compose -f docker-compose.prod.yml up -d +' +``` + +### 3. 验证服务状态 + +```bash +sshpass -p '>n73qBnCja-,#VF+Wq' ssh -o StrictHostKeyChecking=no -p 22 root@101.132.250.62 "curl -s http://localhost:8080/health" +``` + +--- + +## 添加 upload-config 命令到 deploy.sh + +如果你想让 deploy.sh 支持直接上传配置,可以添加以下命令: + +```bash +# 在 deploy.sh 的 main 函数中添加: +upload-config) + print_step "📤 上传配置文件到服务器" + scp_cmd "${SCRIPT_DIR}/docker-compose.prod.yml" "${SERVER_USER}@${SERVER_HOST}:${SERVER_PATH}/" + scp_cmd "${SCRIPT_DIR}/.env.prod" "${SERVER_USER}@${SERVER_HOST}:${SERVER_PATH}/" + print_msg "$GREEN" "✅ 配置文件上传完成" + print_msg "$YELLOW" "请手动重启服务: docker-compose -f docker-compose.prod.yml down && up -d" + ;; +``` + +然后使用方式: +```bash +./deploy.sh upload-config --server 101.132.250.62 +``` + +--- + +## 注意事项 + +1. **不需要重新 build 镜像** - 配置修改不需要重新构建 Docker 镜像 +2. **env_file 优先级** - docker-compose 中 `env_file: .env.prod` 会覆盖 `environment` 中的变量 +3. **敏感信息** - `.env.prod` 包含敏感信息,请勿提交到 Git + +--- + +## 快速验证 + +```bash +# 查看服务状态 +sshpass -p '>n73qBnCja-,#VF+Wq' ssh -o StrictHostKeyChecking=no -p 22 root@101.132.250.62 "docker ps --format 'table {{.Names}}\t{{.Status}}'" + +# 查看环境变量是否生效 +sshpass -p '>n73qBnCja-,#VF+Wq' ssh -o StrictHostKeyChecking=no -p 22 root@101.132.250.62 "docker exec topfans-gateway env | grep OSS" +``` diff --git a/frontend/pages/square/square.vue b/frontend/pages/square/square.vue index 667057f..da35191 100644 --- a/frontend/pages/square/square.vue +++ b/frontend/pages/square/square.vue @@ -955,8 +955,9 @@ const handleCabinClick = (cabin) => { if (Math.abs(velocity) > 0.5) return; // 无用户、或被 banner 遮住(showNickname=false)的小屋不响应点击 if (!cabin.userId || !cabin.showNickname) return; + // 如果是自己的小屋,不需要 target_uid 参数 uni.navigateTo({ - url: `/pages/exhibition/exhibition?target_uid=${cabin.userId}`, + url: cabin.isMine ? '/pages/exhibition/exhibition' : `/pages/exhibition/exhibition?target_uid=${cabin.userId}`, }); }; diff --git a/frontend/utils/api.js b/frontend/utils/api.js index fcfa403..4dcc4b5 100644 --- a/frontend/utils/api.js +++ b/frontend/utils/api.js @@ -1,7 +1,7 @@ // API 基础配置 -// const baseURL = 'http://101.132.250.62:8080' +const baseURL = 'http://101.132.250.62:8080' // const baseURL = 'http://192.168.110.60:8080' -const baseURL = 'http://localhost:8080' +// const baseURL = 'http://localhost:8080' // 是否使用模拟数据(开发调试时设为 true,后端API准备好后改为 false) const USE_MOCK_API = false