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

@ -3,9 +3,10 @@
-- pgvector 不支持 bigint -> vector 直接转换,需逐位拆成 0/1 向量(位 i -> 第 i 维,
-- 与 Go 侧 phash.ToVectorBits 完全一致,保证旧数据与新写入向量在同一语义空间可比)。
--
-- 用法(任选其一):
-- 1) 后端启动时由 AutoMigrate 自动执行(已内置,幂等,无需手动);
-- 2) 手动执行: psql "postgres://fashion:fashion_dev_2026@localhost:5432/fashion" -f 03-migrate-phash-bigint-to-vector.sql
-- 用法(仅升级旧库时需要):
-- 本迁移原先由后端启动时的 AutoMigrate(migratePhashSQL)自动执行;AutoMigrate 已移除,
-- 故升级老库改回手动执行:
-- psql "postgres://fashion:fashion_dev_2026@localhost:5432/fashion" -f 03-migrate-phash-bigint-to-vector.sql
--
-- 已为 vector/text 类型的列自动跳过;可重复执行。

View File

@ -1,7 +1,7 @@
// Command seed_users 预置内部账号(运营/编辑用,不开放公开注册)。
//
// 项目表结构由 GORM AutoMigrate 托管(服务启动时创建);
// 本脚本仅在独立运行、尚未跑过服务时兜底建表,再 upsert 一个内部账号。
// 项目表结构由 cmd/dbtool 导出的 SQL 维护(dbtool dump → psql -f),服务启动时不再自动建表;
// 本脚本为「尚未灌库时也能独立跑」保留一份 users 兜底建表,再 upsert 一个内部账号。
//
// 用法:
// go run ./scripts/seed_users
@ -43,7 +43,7 @@ func main() {
}
}()
// 1. 兜底建表(与 User 模型保持一致;正式结构由服务启动时 AutoMigrate 创建,此处仅作独立运行兜底)
// 1. 兜底建表(与 User 模型保持一致;正式结构由 dbtool dump 的 SQL 创建,此处仅作独立运行兜底)
createSQL := `CREATE TABLE IF NOT EXISTS users (
id bigserial PRIMARY KEY,
created_at bigint NOT NULL DEFAULT 0,