type_bridge.migration.author¶
author
¶
Offline migration artifact authoring (#166).
Authors the complete checked artifact set — reviewable NNNN_name.py,
executable NNNN_name.json sidecar, and immutable snapshots/vNNNN/
files — from two serialized SchemaInfo dictionaries. No TypeDB
connection, no Database, no ModelRegistry, and no live model
classes are involved: this module only marshals inputs into the Rust
authoring core and offers filesystem convenience around its result.
The live makemigrations flow delegates to the same Rust core, so both
paths share one canonical SchemaDiff -> ordered operations mapping.
AuthoredMigration
¶
A complete authored migration artifact set, held in memory.
Wraps the Rust authoring result. files contains every artifact as
(relative_path, bytes) pairs; :meth:write_to persists them through
the validated all-or-nothing writer.
Source code in type_bridge/migration/author.py
write_to
¶
Write all artifacts under migrations_dir.
Existing files must be byte-identical (validate_identical) or
absent (fail); collisions and drift abort before anything is
written. Snapshots stay append-only.
Returns:
| Type | Description |
|---|---|
Path
|
Path to the written migration |
Source code in type_bridge/migration/author.py
author_migration
¶
author_migration(base, target, *, app_label, name, snapshot_version, dependencies=None, previous_snapshot_version=None, before_schema=None, after_schema=None, attribute_renames=None, generated_at=None)
Author the complete migration artifact set from serialized schemas.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base
|
dict[str, Any]
|
Serialized |
required |
target
|
dict[str, Any]
|
Serialized |
required |
app_label
|
str
|
Migrations package name (the migrations directory name). |
required |
name
|
str
|
Full migration stem, e.g. |
required |
snapshot_version
|
str
|
Snapshot version to generate, e.g. |
required |
dependencies
|
list[tuple[str, str]] | None
|
|
None
|
previous_snapshot_version
|
str | None
|
The prior snapshot version ( |
None
|
before_schema
|
list[dict[str, Any]] | None
|
Serialized operations executed before the schema change set (e.g. destructive data cleanup). |
None
|
after_schema
|
list[dict[str, Any]] | None
|
Serialized operations executed after the schema change set (e.g. backfills). |
None
|
attribute_renames
|
list[tuple[str, str]] | None
|
|
None
|
generated_at
|
str | None
|
Explicit timestamp text for the generated |
None
|
Returns:
| Type | Description |
|---|---|
AuthoredMigration | None
|
The authored artifact set, or |
AuthoredMigration | None
|
no explicit operations were supplied. |