Module db

Module db 

Source
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

TypePurpose
SchemaCollection of all tables in a database
TableA 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§

AppliedMigration
Metadata about a migration that has already been applied to a database.
Column
A column in a database table.
ColumnId
Uniquely identifies a column within a schema.
ColumnsDiff
The set of differences between two column lists.
DiffContext
Shared context passed to all diff computations.
Index
A database index over one or more columns of a table.
IndexColumn
A single column entry within an Index.
IndexId
Uniquely identifies an index within a schema.
IndicesDiff
The set of differences between two index lists.
PrimaryKey
The primary key definition for a database table.
RenameHints
Hints that tell the diff algorithm which schema items were renamed.
Schema
The complete database-level schema: a collection of tables.
SchemaDiff
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.
TablesDiff
The set of differences between two table lists.

Enums§

ColumnsDiffItem
A single change detected between two column lists.
IndexOp
The comparison operation used by an index column.
IndexScope
Scope of an index column, relevant for distributed databases.
IndicesDiffItem
A single change detected between two index lists.
Migration
A database migration generated from a SchemaDiff by a driver.
TablesDiffItem
A single change detected between two table lists.
Type
Database-level storage types representing how values are stored in the target database.