Skip to main content

Module diff

Module diff 

Source
Expand description

Model-change migration diffing (ADR-011 revision).

The checked-in migration SQL is the schema of record: we parse the columns a table already has from its generated .sql files (never touching a live database), diff them against the fields declared for the module in gize.toml, and emit the ALTER TABLE needed to reconcile. Additive changes (new columns) are safe and generated automatically; destructive ones (dropping a column) are gated behind --force, and a rename — which at the column level is indistinguishable from a drop plus an add — is always surfaced for a human to decide rather than inferred.

Structs§

SchemaDiff
The schema delta between a module’s declared fields and its migrated columns.

Functions§

alter_sql
Render an ALTER TABLE migration that reconciles table to its declared shape.
diff_model
Compute the diff for model (a module’s declared shape) against the columns already present in its table’s generated migrations under migrations_dir.
known_columns
The set of column names a table already has, parsed from every generated migration that touches it (*_create_<table>.sql and any ALTER TABLE <table> ADD COLUMN). Returns None if the table has no create migration yet.