Skip to content

psql script for managing complex migrations in postgres

License

Notifications You must be signed in to change notification settings

rafonseca/psql-migrate

Repository files navigation

psql-migrate

psql script for managing complex and simple migrations in postgresql

Usage

Ad-hoc migration script

This is used to run a chosen migration script updating ddlog accordingly. We use a psql script (apply-adhoc-migration.sql) to run another psql script, the migration itself. The path to the migration script and the name of the new state (in ddlog) should be stated as the environment variables: NEW_STATE and SQL_PATH. For example:

NEW_STATE=v0.99.0 SQL_PATH=fix_schema_again.sql psql service=target_db -f apply-adhoc-migration.sql

Or using a small wrapper:

NEW_STATE=v0.99.0 SQL_PATH=fix_schema_again.sql apply-adhoc-migration service=target_db 

TODO

  • Define common Data Definition Log schema

  • Implement script to run ad-hoc migration populating ddlog.sql schema

  • Rewrite docs and refactor code to use ddlog.sql

  • Define alternatives for defaut_target definition

  • Implement/refactor script to run graph defined migrations

  • Provide bash functions as wrappers

About

psql script for managing complex migrations in postgres

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published