802 B
802 B
Database Instructions
Scope
- Applies to GORM models in
internal/modelsand migration behavior ininternal/database/database.go.
Rules
- Define explicit foreign keys for non-trivial relations (
foreignKey,references) to avoid inference errors. - Avoid introducing
NOT NULLconstraints on existing populated tables without a backfill plan. - Keep
AutoMigrateadditive-first; prefer safe schema transitions over breaking changes. - Use deterministic ordering fields (
position) for UI-driven entities (kanban sections/tasks). - Ensure seed data aligns with current schema and relation requirements.
Migration Safety
- For legacy data, introduce nullable columns first, backfill, then tighten constraints in a later step.
- Never assume empty tables in shared dev environments.