Module

data.schema.generate

Migration file generator — Operations to numbered .sql files.

Functions

operation_to_sql 1 str
Convert a single operation to SQL.
def operation_to_sql(op: Operation) -> str
Parameters
Name Type Description
op Operation
Returns
str
_next_migration_number 1 int
Find the next migration number by scanning existing files.
def _next_migration_number(migrations_dir: str) -> int
Parameters
Name Type Description
migrations_dir str
Returns
int
_slugify 1 str
Generate a slug from operations for the migration filename.
def _slugify(ops: list[Operation]) -> str
Parameters
Name Type Description
ops list[Operation]
Returns
str
generate_migration 2 str | None
Generate a numbered .sql migration file from operations. Returns the path to t…
def generate_migration(ops: list[Operation], migrations_dir: str = 'migrations') -> str | None

Generate a numbered .sql migration file from operations.

Returns the path to the generated file, or None if no operations.

Parameters
Name Type Description
ops list[Operation]
migrations_dir str Default:'migrations'
Returns
str | None