# Entities, stores and migrations

How you declare the records your app keeps, where they are stored, and how
their shape changes over time. Reading and changing records is
[Reads and writes](/docs/reads-and-writes.md); who may read or change one is
[Policy](/docs/policy.md).

Examples use the golden todo app's `planning` domain, plus a shop where Redis
is needed.

| Page | What it covers |
|---|---|
| [Entities and the id](/docs/entities-and-the-id.md) | An entity is a kind of stored record with a lasting identity, like a table with types. |
| [Fields and their settings](/docs/fields-and-their-settings.md) | A field's settings, such as `generated:`, `unique:` and `on_delete:`, go in a block after its type, one per line. |
| [Unique rules](/docs/unique-rules.md) | `unique: true` in a field's block means no two records may hold the same value in that field. |
| [References and on_delete](/docs/references-and-on-delete.md) | Any field typed `X.id` is a reference to a record of `X`. |
| [Children](/docs/children.md) | A parent doesn't declare its children. |
| [Lifecycle](/docs/lifecycle.md) | A lifecycle describes the stages a record goes through and when it drops out of normal view. |
| [Stores](/docs/stores.md) | A store is somewhere your app keeps records: a PostgreSQL database, or a Redis server. |
| [Structured values](/docs/structured-values.md) | A field whose type is one of your app's enums with data, objects, lists, sets or maps is kept in one `jsonb` column. |
| [Storage types](/docs/storage-types.md) | You never name a column type. |
| [Indexes](/docs/indexes.md) | You don't write the indexes your queries need. |
| [Migrations](/docs/migrations.md) | Entities describe the schema you want. |
| [Computed backfills](/docs/computed-backfills.md) | A backfill can be an expression over each row's own stored fields, so a migration can reshape data rather than only fill it with one value. |
| [Seeds](/docs/seeds.md) | A seed creates data for development by calling your app's own actions, so validation, lifecycle and policy apply to it. |
| [Entities in Redis](/docs/entities-in-redis.md) ○ not built | An entity may live in a Redis store, for data that is short-lived and harmless to lose. |
| [Where things live](/docs/where-things-live.md) | An entity's file holds only its data definition: its store, fields, unique rules, indexes, lifecycle, policy and record cache. |

[What is built](/docs/data-built.md) says which of this works today.

## Details

The exact rules, for when you hit an edge case.

| Page | What it covers |
|---|---|
| [System tables](/docs/system-tables.md) | The runtime needs tables of its own, for example to hold events until they are delivered. |
