Files
digital-psychology/.ai/database.md
T
jackyu66gitandCursor 2fb1dfee14 chore: seal Design Vision v1 and monorepo scaffold
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>
2026-08-02 16:00:44 +08:00

843 B

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.