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

@ -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,