AgentSkillsCN

Data Model + Migration

在本代码库中,采用Ecto + SQLite规范,新增或修改基于数据库的模型。

SKILL.md
--- frontmatter
name: Data Model + Migration
description: Add or change database-backed models using Ecto + SQLite conventions in this codebase.

Scope

Use this skill when introducing or modifying persisted data.

Checklist

  • Generate migrations via mix ecto.gen.migration and update priv/repo/migrations/*.
  • Define schemas in lib/app/model with use App, :model, explicit field types, and timestamps.
  • Validate with App.Validate helpers and App.Field types (e.g. Field.TrimmedString).
  • Avoid casting programmatically-set fields; set them explicitly on the struct when creating records.
  • Use Ecto.Changeset.get_field/2 to read changeset values (no access syntax).
  • Preload associations before rendering in templates.
  • Add or update fixtures in test/support/fixtures when tests need new data.