Expand description
Database-level (table/column-oriented) schema definitions. Database-level schema definitions.
This module represents what the database sees: tables, columns, indices,
primary keys, storage types, and migrations. It is the counterpart to the
application-level schema in [super::app], with the two layers connected
by the [super::mapping] module.
§Key types
| Type | Purpose |
|---|---|
Schema | Collection of all tables in a database |
Table | A single database table with columns, indices, and a primary key |
[Column] | A column within a table, including its name, type, and constraints |
[Index] | A database index over one or more columns |
[Type] | Database storage type (e.g. Integer(4), Text, VarChar(255)) |
[PrimaryKey] | The primary key definition for a table |
[Migration] | A SQL migration generated from a schema diff |
§Schema diffing
The module provides diff types ([SchemaDiff], [TablesDiff], [ColumnsDiff],
[IndicesDiff]) that compare two schema versions and produce a list of
structural changes. [RenameHints] lets callers indicate which items were
renamed (rather than dropped and recreated).
Structs§
- Applied
Migration - Metadata about a migration that has already been applied to a database.
- Column
- A column in a database table.
- Column
Id - Uniquely identifies a column within a schema.
- Columns
Diff - The set of differences between two column lists.
- Diff
Context - Shared context passed to all diff computations.
- Index
- A database index over one or more columns of a table.
- Index
Column - A single column entry within an
Index. - IndexId
- Uniquely identifies an index within a schema.
- Indices
Diff - The set of differences between two index lists.
- Primary
Key - The primary key definition for a database table.
- Rename
Hints - Hints that tell the diff algorithm which schema items were renamed.
- Schema
- The complete database-level schema: a collection of tables.
- Schema
Diff - The top-level diff between two database schemas.
- Table
- A database table with its columns, primary key, and indices.
- TableId
- Uniquely identifies a table within a
Schema. - Tables
Diff - The set of differences between two table lists.
Enums§
- Columns
Diff Item - A single change detected between two column lists.
- IndexOp
- The comparison operation used by an index column.
- Index
Scope - Scope of an index column, relevant for distributed databases.
- Indices
Diff Item - A single change detected between two index lists.
- Migration
- A database migration generated from a
SchemaDiffby a driver. - Tables
Diff Item - A single change detected between two table lists.
- Type
- Database-level storage types representing how values are stored in the target database.