migration
Database Migrations: Configure and Run
postgresql_migrations · Database Migrations: Configure and Run
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100673 | migration | postgresql_migrations | 0.0.1 | ETL | Unlicense | SQL |
| Relationships | |
|---|---|
| Requires | plpgsql |
Usage
Sources:
migration 0.0.1 is a database-resident migration runner. It registers numbered up/down SQL files, reads those files from the PostgreSQL server filesystem, executes them dynamically, and records status. It is an old administrative tool, not a safe migration service for untrusted users.
Core Workflow
Place reviewed SQL files on the database server, choose a stable root directory, register them in order, and use one administrative session to migrate.
Object Index
migration_registrystores the numeric migration, up/down file paths, and applied status.migration_set_env(text, text)and related environment helpers manage values such as the server-side root directory.register_migration(...)records file paths; it does not freeze or checksum their contents.migration_run(...)executes one direction, whilemigration_migrate_database(numeric)walks the registry toward a target version.
Security and Operations
- File access occurs on the PostgreSQL server through server-side COPY, and file contents are executed as SQL. Restrict the extension and its functions to trusted administrators.
- Keep registered files immutable, reviewed, and backed up. The registry stores paths rather than content hashes, so replacing a file changes what a later run executes.
- Run only one migrator at a time. The implementation provides no advisory-lock protocol for concurrent runners.
- Test both up and down paths on a disposable copy and take a database backup. Error rows help diagnosis but are not a substitute for transactional review or recovery planning.