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.
pub type Snapshot {
Snapshot(tables: dict.Dict(String, TableSnapshot))
}
Constructors
-
Snapshot(tables: dict.Dict(String, TableSnapshot))
Snapshot of a single table’s column definitions.
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.
pub fn column_type_to_string(
col_type: schema_parser.ColumnType,
) -> String
Convert a ColumnType to its string representation for snapshots.
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.