{"id":21374507,"url":"https://github.com/phillbaker/pg_migrate","last_synced_at":"2025-07-13T09:32:00.752Z","repository":{"id":66875203,"uuid":"450327251","full_name":"phillbaker/pg_migrate","owner":"phillbaker","description":"Reorganize tables in PostgreSQL databases with minimal locks","archived":false,"fork":false,"pushed_at":"2024-02-11T23:09:38.000Z","size":1049,"stargazers_count":14,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-07T08:02:03.756Z","etag":null,"topics":["migrations","pg","postgres","postgresql"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phillbaker.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-01-21T02:30:08.000Z","updated_at":"2024-10-21T09:34:44.000Z","dependencies_parsed_at":"2024-02-12T00:25:16.101Z","dependency_job_id":"93a5aad0-d5dc-4e65-bc17-3cdc6acbca10","html_url":"https://github.com/phillbaker/pg_migrate","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/phillbaker/pg_migrate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phillbaker%2Fpg_migrate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phillbaker%2Fpg_migrate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phillbaker%2Fpg_migrate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phillbaker%2Fpg_migrate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phillbaker","download_url":"https://codeload.github.com/phillbaker/pg_migrate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phillbaker%2Fpg_migrate/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265120110,"owners_count":23714488,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["migrations","pg","postgres","postgresql"],"created_at":"2024-11-22T08:43:17.138Z","updated_at":"2025-07-13T09:32:00.407Z","avatar_url":"https://github.com/phillbaker.png","language":"C","readme":"# pg_migrate -- Perform schema changes in PostgreSQL with minimal locks\n\n- Download: https://github.com/phillbaker/pg_migrate/releases\n- Development: https://github.com/phillbaker/pg_migrate\n- Bug Reports: https://github.com/phillbaker/pg_migrate/issues\n\n\n\n## About\n\npg_migrate is a PostgreSQL extension and CLI which lets you make schema\nchanges to tables and indexes. Unlike `ALTER TABLE` it works online, without\nholding a long lived exclusive lock on the processed tables during the\nmigration. It builds a copy of the target table and swaps them.\n\nPlease check the documentation (in the ``doc`` directory or online) for\ninstallation and usage instructions.\n\nForked from the excellent pg_repack project (https://reorg.github.io/pg_repack).\n\n## Supported Postgres Versions\n\nPostgres \u003e= 9.6\n\n## Installation\n\n### Ubuntu/Debian\n\nUse `apt-get` to install the package matching the Postgres version (`postgresql-\u003cversion\u003e-pg_migrate`) being run from [this repo's APT repository](https://github.com/phillbaker/pg_migrate/releases/tag/apt-release-amd64).\n\nTo add to your `/etc/apt/sources.list.d`, add the signing GPG key, and update the package DB, run:\n\n```\ncurl -L https://github.com/phillbaker/pg_migrate/releases/download/apt-release-amd64/apt-add-repo | sh\n```\n\nThen to install, for example, for Postgres 10:\n```\napt-get install -y postgresql-10-pg_migrate\n```\n\nLoad the pg_migrate Postgres extension in the database you want to work on:\n```\npsql -c \"DROP EXTENSION IF EXISTS pg_migrate cascade; CREATE EXTENSION pg_migrate\" -d postgres\n```\n\n### Mac\n\nUse `homebrew` to install the package matching the Postgres version being used.\n\n```\nbrew tap phillbaker/pg_migrate https://github.com/phillbaker/pg_migrate\nbrew install pg_migrate_postgresql@10\n# follow the post install instructions if you're running postgres on your local machine\n```\n\n## Examples\n\n### Change the type of a column\n\n```\npg_migrate --table=my_table --alter='ALTER COLUMN id TYPE bigint' # Add --execute to run\n```\n\n### Add a column with a default (non-nullable)\n\n```\npg_migrate --table=my_table --alter='ADD COLUMN foo integer NOT NULL DEFAULT 42' # Add --execute to run\n```\n\n## Known Limitations\n\n* Unique constraints are converted into unique indexes, [they are equivalent in Postgres](https://stackoverflow.com/questions/23542794/postgres-unique-constraint-vs-index). However, this may be an unexpected change.\n* Index names on the target table and foreign key constraints are changed during the migration.\n  * If the generated names are \u003e 63 characters, this will likely break\n* If the target table is used in views, those objects will continue to reference the original table - this is not supported currently.\n  * If the target table is used in stored procedures, those functions are stored as text so are not linked through object IDs and will reference the migrated table.\n* DDL to drop columns or add columns without a default is not currently supported\n* Hosted PG databases (RDS, Cloud SQL) are not supported because they do not allow installing custom extensions.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphillbaker%2Fpg_migrate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphillbaker%2Fpg_migrate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphillbaker%2Fpg_migrate/lists"}