修复时间字段命名:createdate/modifydate 改为 snake_case

This commit is contained in:
fish
2026-04-13 21:41:15 +08:00
parent dc1056ffb0
commit 0187160401
4 changed files with 19 additions and 19 deletions

View File

@@ -61,7 +61,7 @@ backend/
### 数据库模型
核心表结构(见 `services/user-service/migrations/001_init.sql`
- `user_main(id UUID PK, deleted BOOLEAN, createdate, modifydate)`
- `user_main(id UUID PK, deleted BOOLEAN, create_date, modify_date)`
- `user_login_account(id UUID PK, user_id FK, account VARCHAR)`
- `user_login_email(id UUID PK, user_id FK, email VARCHAR)`
- `user_login_password(id UUID PK, user_id FK, password VARCHAR)`
@@ -164,15 +164,15 @@ OK
### 3. 时间字段约定
所有表中的 `createdate` 和 `modifydate` **必须由业务层生成并传入**数据库Schema中**不设置** `DEFAULT CURRENT_TIMESTAMP`,也不使用触发器自动更新。
所有表中的 `create_date` 和 `modify_date` **必须由业务层生成并传入**数据库Schema中**不设置** `DEFAULT CURRENT_TIMESTAMP`,也不使用触发器自动更新。
- 建表时:
```sql
createdate TIMESTAMP WITH TIME ZONE NOT NULL,
modifydate TIMESTAMP WITH TIME ZONE NOT NULL
create_date TIMESTAMP WITH TIME ZONE NOT NULL,
modify_date TIMESTAMP WITH TIME ZONE NOT NULL
```
- Rust 代码中使用 `chrono::Utc::now()` 生成时间戳,统一在事务开始前创建 `let now = Utc::now();`,确保同一笔业务中各表时间一致。
- `modifydate` 更新时同样需要在业务代码中显式传入 `Utc::now()`。
- `modify_date` 更新时同样需要在业务代码中显式传入 `Utc::now()`。
### 4. 环境变量