Archive the differentiated YuXinGu product docs, AI engineering system, design contract, and Go/Vue scaffold. Next execution prioritizes Cece-parity over early innovation (see .ai/product/STRATEGY.md). Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
843 B
Markdown
40 lines
843 B
Markdown
# Database — Golden Rules
|
|
|
|
## Naming
|
|
|
|
- `snake_case` only for tables and columns.
|
|
- Good: `user_profile`, `payment_order`, `user_session`.
|
|
- Forbidden prefixes: `tbl_`, `t_`.
|
|
|
|
## Required columns on business tables
|
|
|
|
```
|
|
id
|
|
created_at
|
|
updated_at
|
|
deleted_at
|
|
```
|
|
|
|
## Types
|
|
|
|
- Never `varchar(5000)` as a habit.
|
|
- Prefer bounded `varchar(n)`.
|
|
- `TEXT` only when necessary (long content bodies).
|
|
- Timestamps: `timestamptz`.
|
|
|
|
## Keys & indexes
|
|
|
|
- Every foreign key indexed.
|
|
- Unique business keys enforced with UNIQUE.
|
|
|
|
## Migrations
|
|
|
|
- Schema change without migration = incomplete feature.
|
|
- Migrations live in `apps/api/migrations/`.
|
|
- Provide Up and Down when tool supports it.
|
|
|
|
## Soft delete
|
|
|
|
- Default: set `deleted_at`, do not hard delete user content in MVP.
|
|
- Queries must filter `deleted_at IS NULL` unless explicitly including deleted.
|