Skip to main content

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 types live in [`super::diff`].
21
22mod column;
23pub use column::{Column, ColumnId};
24
25mod index;
26pub use index::{Index, IndexColumn, IndexId, IndexOp, IndexScope};
27
28mod migration;
29pub use migration::{AppliedMigration, Migration};
30
31mod pk;
32pub use pk::PrimaryKey;
33
34mod schema;
35pub use schema::Schema;
36
37mod table;
38pub use table::{Table, TableId};
39
40mod ty;
41mod ty_enum;
42pub use ty_enum::{EnumVariant, TypeEnum};
43
44pub use ty::Type;