This commit is contained in:
toom1996
2026-09-21 19:19:03 +08:00
parent dffcf9f9e5
commit 299fd974df
11 changed files with 3392 additions and 575 deletions

View File

@ -8,13 +8,12 @@ build:
run: build
./bin/server
# 表结构由 GORM AutoMigrate 在 server 启动时幂等创建,无需手动 SQL。
# 跨环境搬运全库数据(结构 + 数据)用 dbtool:
# go run ./cmd/dbtool dump -out db_dump.json
# go run ./cmd/dbtool import -in db_dump.json # 整机重建
# go run ./cmd/dbtool import -in db_dump.json -data-only # 仅导数据(结构已由 AutoMigrate 建好)
# 表结构不由服务启动自动创建:全库「结构 + 索引 + 数据」统一由 dbtool 导出的 SQL 维护。
# 导出:go run ./cmd/dbtool dump -out db/backups/db_dump.sql
# 导入:psql -U fashion -d fashion -v ON_ERROR_STOP=1 -f db/backups/db_dump.sql
# 目标库须为空且已启用 pgvector 扩展(导入时可加 -with-extension 让 dump 自带 CREATE EXTENSION)。
migrate:
@echo "Schema is auto-migrated by server on startup (GORM AutoMigrate). Use 'go run ./cmd/dbtool' to move data between environments."
@echo "Schema is maintained by 'go run ./cmd/dbtool dump' -> psql -f (server no longer auto-migrates)."
# 跑单测
test: