Skip to main content

Module migration

Module migration 

Source
Expand description

Database migration system. Lives under pg/ with the rest of the Postgres primitives so the doctrine “all PG-touching code goes through forge_runtime::pg” is enforced by layout, not just by convention.

§Migration types

  • System migrations: internal Forge schema, versioned as __forge_vXXX. Applied before user migrations so new framework features can ship without conflicting with user migration numbering.
  • User migrations: application schema, named XXXX_name.sql. Sorted alphabetically and applied after system migrations.

Structs§

AppliedMigration
Information about an applied migration.
Migration
A single migration with up SQL.
MigrationConfig
Tunable knobs for the migration runner. Defaults match the deploy-friendly values: bounded lock-acquire wait so a stuck lock fails CI loudly instead of hanging silently.
MigrationRunner
Migration runner that handles both built-in and user migrations.
MigrationStatus
Status of migrations.
SystemMigration
A system migration with a version number.

Enums§

DriftStatus
Whether the on-disk source for an already-applied migration still matches the checksum recorded at apply time.

Constants§

SYSTEM_MIGRATION_PREFIX
System migration prefix. All forge internal migrations use this prefix.

Functions§

extract_version
Returns None if name is not a valid system migration name.
get_all_system_sql
All system SQL concatenated. Use for test setup; production code should use get_builtin_migrations.
get_builtin_migrations
get_system_migrations
All built-in FORGE system migrations in version order.
is_system_migration
load_migrations_from_dir
Load user migrations from a directory.