Skip to main content

Module migration_support

Module migration_support 

Source
Expand description

Shared helpers for emitting SeaORM migration files that call the doido_model::migration builders (create_table, alter_table, drop_table, add_index, …) instead of raw sea-orm boilerplate.

Used by both the model generator (which creates a table for a new model) and the migration generator.

Constants§

MIGRATION_LIB_BASE
Fallback migration lib.rs used when the app doesn’t have one on disk yet; kept in sync with the generated-app template so injection markers line up.
MIGRATION_SRC_DIR
Directory holding the SeaORM migration crate’s sources.

Functions§

create_table_imports
The doido_model::migration import line for a create_table migration — pulls in add_index only when a field requested an index, so generated code carries no unused imports.
create_table_up
Builds the up() body for a create_table migration — a create_table call carrying the declared columns, followed by any add_index calls for :index fields.
drop_table_down
The down() body that drops a table: drop_table(manager, "<table>").await.
register_migration
Inserts a mod <module>; declaration and a Box::new(<module>::Migration) registration into the migration crate’s lib.rs, just above the generator markers. Indentation of the list entry mirrors the marker line.
render_migration_file
Renders a full migration file from the imports line and the up/down bodies (each already indented as an async fn body ending in a newline).