toasty_core/schema/db.rs
1//! Database-level schema definitions.
2//!
3//! This module represents what the database sees: tables, columns, indices,
4//! primary keys, storage types, and migrations. It is the counterpart to the
5//! application-level schema in [`super::app`], with the two layers connected
6//! by the [`super::mapping`] module.
7//!
8//! # Key types
9//!
10//! | Type | Purpose |
11//! |------|---------|
12//! | [`Schema`] | Collection of all tables in a database |
13//! | [`Table`] | A single database table with columns, indices, and a primary key |
14//! | [`Column`] | A column within a table, including its name, type, and constraints |
15//! | [`Index`] | A database index over one or more columns |
16//! | [`Type`] | Database storage type (e.g. `Integer(4)`, `Text`, `VarChar(255)`) |
17//! | [`PrimaryKey`] | The primary key definition for a table |
18//! | [`Migration`] | A SQL migration generated from a schema diff |
19//!
20//! # Schema diffing
21//!
22//! The module provides diff types ([`SchemaDiff`], [`TablesDiff`], [`ColumnsDiff`],
23//! [`IndicesDiff`]) that compare two schema versions and produce a list of
24//! structural changes. [`RenameHints`] lets callers indicate which items were
25//! renamed (rather than dropped and recreated).
26
27mod column;
28pub use column::{Column, ColumnId, ColumnsDiff, ColumnsDiffItem};
29
30mod diff;
31pub use diff::{DiffContext, RenameHints};
32
33mod index;
34pub use index::{Index, IndexColumn, IndexId, IndexOp, IndexScope, IndicesDiff, IndicesDiffItem};
35
36mod migration;
37pub use migration::{AppliedMigration, Migration};
38
39mod pk;
40pub use pk::PrimaryKey;
41
42mod schema;
43pub use schema::{Schema, SchemaDiff};
44
45mod table;
46pub use table::{Table, TableId, TablesDiff, TablesDiffItem};
47
48mod ty;
49pub use ty::Type;