{"id":28816774,"url":"https://github.com/pgschema/pgschema","last_synced_at":"2026-01-31T08:06:13.832Z","repository":{"id":298277792,"uuid":"998434422","full_name":"pgschema/pgschema","owner":"pgschema","description":"Terraform-style, declarative schema migration for Postgres","archived":false,"fork":false,"pushed_at":"2026-01-12T11:31:24.000Z","size":4073,"stargazers_count":547,"open_issues_count":4,"forks_count":23,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-01-12T19:23:35.620Z","etag":null,"topics":["cicd","ddl","devops","gitops","multi-tenant","postgres","postgresql","schema","schema-change","schema-diff","schema-migration","schema-migrations","terraform"],"latest_commit_sha":null,"homepage":"https://www.pgschema.com","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pgschema.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-08T15:50:01.000Z","updated_at":"2026-01-12T11:31:28.000Z","dependencies_parsed_at":"2025-12-29T13:07:07.811Z","dependency_job_id":null,"html_url":"https://github.com/pgschema/pgschema","commit_stats":null,"previous_names":["pgschema/pgschema"],"tags_count":26,"template":false,"template_full_name":null,"purl":"pkg:github/pgschema/pgschema","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgschema%2Fpgschema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgschema%2Fpgschema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgschema%2Fpgschema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgschema%2Fpgschema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgschema","download_url":"https://codeload.github.com/pgschema/pgschema/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgschema%2Fpgschema/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28515630,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T18:28:00.501Z","status":"ssl_error","status_checked_at":"2026-01-17T18:28:00.150Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["cicd","ddl","devops","gitops","multi-tenant","postgres","postgresql","schema","schema-change","schema-diff","schema-migration","schema-migrations","terraform"],"created_at":"2025-06-18T17:06:54.911Z","updated_at":"2026-01-31T08:06:13.824Z","avatar_url":"https://github.com/pgschema.png","language":"Go","readme":"\u003e [!NOTE]  \n\u003e Brought to you by [Bytebase](https://www.bytebase.com/), open-source database DevSecOps platform.\n\n![light-banner](https://raw.githubusercontent.com/pgschema/pgschema/main/docs/logo/light.png#gh-light-mode-only)\n![dark-banner](https://raw.githubusercontent.com/pgschema/pgschema/main/docs/logo/dark.png#gh-dark-mode-only)\n\n\u003ca href=\"https://www.star-history.com/#pgschema/pgschema\u0026Date\"\u003e\n \u003cpicture\u003e\n   \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://api.star-history.com/svg?repos=pgschema/pgschema\u0026type=Date\u0026theme=dark\" /\u003e\n   \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://api.star-history.com/svg?repos=pgschema/pgschema\u0026type=Date\" /\u003e\n   \u003cimg alt=\"Star History Chart\" src=\"https://api.star-history.com/svg?repos=pgschema/pgschema\u0026type=Date\" /\u003e\n \u003c/picture\u003e\n\u003c/a\u003e\n\n`pgschema` is a CLI tool that brings terraform-style declarative schema migration workflow to Postgres:\n\n- **Dump** a Postgres schema in a developer-friendly format with support for all common objects\n- **Edit** a schema to the desired state\n- **Plan** a schema migration by comparing desired state with current database state\n- **Apply** a schema migration with concurrent change detection, transaction-adaptive execution, and lock timeout control\n\nThink of it as Terraform for your Postgres schemas - declare your desired state, generate plan, preview changes, and apply them with confidence.\n\n## Key differentiators from other tools\n\n1. **Comprehensive Postgres Support**: Handles virtually all schema-level database objects across Postgres versions 14 through 18\n1. **State-Based Terraform-Like Workflow**: No separate migration table needed to track migration history - determines changes by comparing your schema files with actual database state\n1. **Schema-Level Focus**: Designed for real-world Postgres usage patterns, from single-schema applications to multi-tenant architectures\n1. **No Shadow Database Required**: Works directly with your schema files and target database - no temporary databases needed for validation\n\nSee more details in the [introduction blog post](https://www.pgschema.com/blog/pgschema-postgres-declarative-schema-migration-like-terraform).\n\nWatch in action:\n\n[![asciicast](https://asciinema.org/a/vXHygDMUkGYsF6nmz2h0ONEQC.svg)](https://asciinema.org/a/vXHygDMUkGYsF6nmz2h0ONEQC)\n\n## Installation\n\nVisit https://www.pgschema.com/installation\n\n\u003e [!NOTE]\n\u003e Windows is not supported. Please use WSL (Windows Subsystem for Linux) or a Linux VM.\n\n## Getting help\n\n- [Docs](https://www.pgschema.com)\n- [GitHub issues](https://github.com/pgschema/pgschema/issues)\n\n## Quick example\n\n### Step 1: Dump schema\n\n```bash\n# Dump current schema\n$ PGPASSWORD=testpwd1 pgschema dump \\\n    --host localhost \\\n    --db testdb \\\n    --user postgres \\\n    --schema public \u003e schema.sql\n```\n\n### Step 2: Edit schema\n\n```bash\n# Edit schema file declaratively\n--- a/schema.sql\n+++ b/schema.sql\n@@ -12,5 +12,6 @@\n\n CREATE TABLE IF NOT EXISTS users (\n     id SERIAL PRIMARY KEY,\n-    username varchar(50) NOT NULL UNIQUE\n+    username varchar(50) NOT NULL UNIQUE,\n+    age INT NOT NULL\n );\n```\n\n### Step 3: Generate plan\n\n```bash\n$ PGPASSWORD=testpwd1 pgschema plan \\\n    --host localhost \\\n    --db testdb \\\n    --user postgres \\\n    --schema public \\\n    --file schema.sql \\\n    --output-human stdout \\\n    --output-json plan.json\n\nPlan: 1 to modify.\n\nSummary by type:\n  tables: 1 to modify\n\nTables:\n  ~ users\n    + age (column)\n\nTransaction: true\n\nDDL to be executed:\n--------------------------------------------------\n\nALTER TABLE users ADD COLUMN age integer NOT NULL;\n```\n\n### Step 4: Apply plan with confirmation\n\n```bash\n# Or use --auto-approve to skip confirmation\n$ PGPASSWORD=testpwd1 pgschema apply \\\n    --host localhost \\\n    --db testdb \\\n    --user postgres \\\n    --schema public \\\n    --plan plan.json\n\nPlan: 1 to modify.\n\nSummary by type:\n  tables: 1 to modify\n\nTables:\n  ~ users\n    + age (column)\n\nTransaction: true\n\nDDL to be executed:\n--------------------------------------------------\n\nALTER TABLE users ADD COLUMN age integer NOT NULL;\n\nDo you want to apply these changes? (yes/no): yes\n\nApplying changes...\nChanges applied successfully!\n```\n\n## LLM Readiness\n\n- https://www.pgschema.com/llms.txt\n- https://www.pgschema.com/llms-full.txt\n\n![_](https://raw.githubusercontent.com/pgschema/pgschema/main/docs/images/copy-page.webp)\n\n## Development\n\n\u003e [!NOTE] \u003e **For external contributors**: If you require any features, please create a GitHub issue to discuss first instead of creating a PR directly.\n\n### Build\n\n```bash\ngit clone https://github.com/pgschema/pgschema.git\ncd pgschema\ngo mod tidy\ngo build -o pgschema .\n```\n\n### Run tests\n\n```bash\n# Run unit tests only\ngo test -short -v ./...\n\n# Run all tests including integration tests (uses Postgres testcontainers with Docker)\ngo test -v ./...\n```\n\n## Sponsor\n\n[Bytebase](https://www.bytebase.com?utm_sourcepgschema) - open source, web-based database DevSecOps platform.\n\n\u003ca href=\"https://www.bytebase.com?utm_sourcepgschema\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/pgschema/pgschema/main/docs/images/bytebase.webp\" /\u003e\u003c/a\u003e\n","funding_links":[],"categories":["Go","\u003ca name=\"Go\"\u003e\u003c/a\u003eGo"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgschema%2Fpgschema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgschema%2Fpgschema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgschema%2Fpgschema/lists"}