glimr/db/gen/migrate/snapshot
Migration Snapshot
Handles schema snapshots for migration diffing. Snapshots capture the current state of table schemas and are stored as JSON between migration runs to detect changes.
Types
Snapshot of a single column’s properties including name, type, nullability, and whether it has a default value.
pub type ColumnSnapshot {
ColumnSnapshot(
name: String,
column_type: String,
nullable: Bool,
has_default: Bool,
)
}
Constructors
-
ColumnSnapshot( name: String, column_type: String, nullable: Bool, has_default: Bool, )
Snapshot of all table schemas, stored as JSON between runs. Used to detect what has changed since the last migration by comparing against the current schema definitions.
pub type Snapshot {
Snapshot(tables: dict.Dict(String, TableSnapshot))
}
Constructors
-
Snapshot(tables: dict.Dict(String, TableSnapshot))
Snapshot of a single table’s column definitions. Contains the list of columns in their definition order for accurate migration diffing.
pub type TableSnapshot {
TableSnapshot(columns: List(ColumnSnapshot))
}
Constructors
-
TableSnapshot(columns: List(ColumnSnapshot))
Values
pub fn build(tables: List(schema_parser.Table)) -> Snapshot
Build a new snapshot from a list of parsed Table schemas. Converts each table’s columns to ColumnSnapshot format for JSON serialization.
pub fn column_type_to_string(
col_type: schema_parser.ColumnType,
) -> String
Convert a ColumnType to its string representation for snapshots. Maps each variant to a consistent string format used in the JSON snapshot files.
pub fn load(path: String) -> Snapshot
Load the schema snapshot from a JSON file. Returns an empty snapshot if the file doesn’t exist or can’t be parsed, allowing first-run migration generation.