{"id":13465148,"url":"https://github.com/salsita/node-pg-migrate","last_synced_at":"2026-01-16T10:54:26.320Z","repository":{"id":15003619,"uuid":"17729096","full_name":"salsita/node-pg-migrate","owner":"salsita","description":"Node.js database migration management for PostgreSQL","archived":false,"fork":false,"pushed_at":"2026-01-13T17:50:27.000Z","size":5857,"stargazers_count":1431,"open_issues_count":56,"forks_count":188,"subscribers_count":11,"default_branch":"main","last_synced_at":"2026-01-13T22:00:15.342Z","etag":null,"topics":["api","cockroach","cockroachdb","database","db","db-migrate","expandable","extensible","migrate","migration","migrations","migrator","pg","postgre","postgres","postgresql","programable","programatic","sql"],"latest_commit_sha":null,"homepage":"https://salsita.github.io/node-pg-migrate","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"mpociot/captainhook","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/salsita.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/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":"2014-03-13T23:09:22.000Z","updated_at":"2026-01-12T18:20:20.000Z","dependencies_parsed_at":"2026-01-13T22:00:38.030Z","dependency_job_id":null,"html_url":"https://github.com/salsita/node-pg-migrate","commit_stats":{"total_commits":1178,"total_committers":80,"mean_commits":14.725,"dds":0.5797962648556876,"last_synced_commit":"c50d7cadc7c7bfde74b636832140d4ff69dcad31"},"previous_names":["theoephraim/node-pg-migrate"],"tags_count":187,"template":false,"template_full_name":null,"purl":"pkg:github/salsita/node-pg-migrate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salsita%2Fnode-pg-migrate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salsita%2Fnode-pg-migrate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salsita%2Fnode-pg-migrate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salsita%2Fnode-pg-migrate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/salsita","download_url":"https://codeload.github.com/salsita/node-pg-migrate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salsita%2Fnode-pg-migrate/sbom","scorecard":{"id":796668,"data":{"date":"2025-08-11","repo":{"name":"github.com/salsita/node-pg-migrate","commit":"57702bf52648eeacbb6d3c702d303a0104c15a5d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":6.1,"checks":[{"name":"Maintained","score":10,"reason":"30 commit(s) and 12 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":8,"reason":"Found 11/13 approved changesets -- score normalized to 8","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: jobLevel 'statuses' permission set to 'write': .github/workflows/semantic-pull-request.yml:17","Info: jobLevel 'pull-requests' permission set to 'read': .github/workflows/semantic-pull-request.yml:16","Info: topLevel 'contents' permission set to 'read': .github/workflows/ci.yml:11","Info: topLevel 'contents' permission set to 'read': .github/workflows/cockroach-test.yml:11","Warn: no topLevel permission defined: .github/workflows/coverage-report.yml:1","Info: topLevel 'contents' permission set to 'read': .github/workflows/coverage.yml:9","Info: topLevel 'contents' permission set to 'read': .github/workflows/docs.yml:14","Info: topLevel 'contents' permission set to 'read': .github/workflows/postgres-test.yml:11","Warn: no topLevel permission defined: .github/workflows/publish.yml:1","Info: found token with 'none' permissions: .github/workflows/semantic-pull-request.yml:1"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":10,"reason":"all dependencies are pinned","details":["Info:  54 out of  54 GitHub-owned GitHubAction dependencies pinned","Info:  25 out of  25 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":8,"reason":"2 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-xffm-g5w8-qvg7","Warn: Project is vulnerable to: GHSA-67mh-4wv8-2f99"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T09:12:20.263Z","repository_id":15003619,"created_at":"2025-08-23T09:12:20.263Z","updated_at":"2025-08-23T09:12:20.263Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478090,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"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":["api","cockroach","cockroachdb","database","db","db-migrate","expandable","extensible","migrate","migration","migrations","migrator","pg","postgre","postgres","postgresql","programable","programatic","sql"],"created_at":"2024-07-31T14:01:01.348Z","updated_at":"2026-01-16T10:54:26.315Z","avatar_url":"https://github.com/salsita.png","language":"TypeScript","readme":"# node-pg-migrate\n\n[![npm version](https://badgen.net/npm/v/node-pg-migrate)](https://www.npmjs.com/package/node-pg-migrate)\n[![npm downloads](https://badgen.net/npm/dm/node-pg-migrate)](https://www.npmjs.com/package/node-pg-migrate)\n[![Continuous Integration](https://github.com/salsita/node-pg-migrate/actions/workflows/ci.yml/badge.svg)](https://github.com/salsita/node-pg-migrate/actions/workflows/ci.yml)\n[![Postgres Test](https://github.com/salsita/node-pg-migrate/actions/workflows/postgres-test.yml/badge.svg)](https://github.com/salsita/node-pg-migrate/actions/workflows/postgres-test.yml)\n[![Cockroach Test](https://github.com/salsita/node-pg-migrate/actions/workflows/cockroach-test.yml/badge.svg)](https://github.com/salsita/node-pg-migrate/actions/workflows/cockroach-test.yml)\n![Licence](https://img.shields.io/npm/l/node-pg-migrate.svg?style=flat)\n\nNode.js database migration management built exclusively for postgres. (But can also be used for other DBs conforming to SQL standard - e.g. [CockroachDB](https://github.com/cockroachdb/cockroach).)  \nStarted by [Theo Ephraim](https://github.com/theoephraim/), then handed over to [Salsita Software](https://www.salsitasoft.com/) and now maintained by [@Shinigami92](https://github.com/Shinigami92).\n\n## Preconditions\n\n- Node.js 20.11 or higher\n- PostgreSQL 13 or higher (lower versions may work but are not supported officially)\n\nIf you don't already have the [`pg`](https://node-postgres.com/) library installed, you will need to add pg as either a direct or dev dependency\n\n```bash\nnpm add pg\n```\n\n## Installation\n\n```bash\nnpm add --save-dev node-pg-migrate\n```\n\nInstalling this module adds a runnable file into your `node_modules/.bin` directory. If installed globally (with the -g option), you can run `node-pg-migrate` and if not, you can run `./node_modules/.bin/node-pg-migrate.js`\n\n## Quick Example\n\nAdd `\"migrate\": \"node-pg-migrate\"` to `scripts` section of your `package.json` so you are able to quickly run commands.\n\nRun `npm run migrate create my-first-migration`. It will create file `xxx_my-first-migration.js` in `migrations` folder.  \nOpen it and change contents to:\n\n```js\nexport const up = (pgm) =\u003e {\n  pgm.createTable('users', {\n    id: 'id',\n    name: { type: 'varchar(1000)', notNull: true },\n    createdAt: {\n      type: 'timestamp',\n      notNull: true,\n      default: pgm.func('current_timestamp'),\n    },\n  });\n  pgm.createTable('posts', {\n    id: 'id',\n    userId: {\n      type: 'integer',\n      notNull: true,\n      references: '\"users\"',\n      onDelete: 'CASCADE',\n    },\n    body: { type: 'text', notNull: true },\n    createdAt: {\n      type: 'timestamp',\n      notNull: true,\n      default: pgm.func('current_timestamp'),\n    },\n  });\n  pgm.createIndex('posts', 'userId');\n};\n```\n\nSave migration file.\n\nNow you should put your DB connection string to `DATABASE_URL` environment variable and run `npm run migrate up`.\n(e.g. `DATABASE_URL=postgres://test:test@localhost:5432/test npm run migrate up`)\n\nYou should now have two tables in your DB :tada:\n\nIf you want to change your schema later, you can e.g. add lead paragraph to posts:\n\nRun `npm run migrate create posts_lead`, edit `xxx_posts_lead.js`:\n\n```js\nexport const up = (pgm) =\u003e {\n  pgm.addColumns('posts', {\n    lead: { type: 'text', notNull: true },\n  });\n};\n```\n\nRun `npm run migrate up` and there will be a new column in `posts` table :tada:\n\nWant to know more? Read docs:\n\n## Docs\n\nFull docs are available at https://salsita.github.io/node-pg-migrate\n\n## Explanation \u0026 Goals\n\n_Why only Postgres?_ - By writing this migration tool specifically for postgres instead of accommodating many databases, we can actually provide a full featured tool that is much simpler to use and maintain. I was tired of using crippled database tools just in case one day we switch our database.\n\n_Async / Sync_ - Everything is async in node, and that's great, but a migration tool should really just be a fancy wrapper that generates SQL. Most other migration tools force you to bring in control flow libraries or wrap everything in callbacks as soon as you want to do more than a single operation in a migration. Plus by building up a stack of operations, we can automatically infer down migrations (sometimes) to save even more time.\n\n_Naming / Raw Sql_ - Many tools force you to use their constants to do things like specify data types. Again, this tool should be a fancy wrapper that generates SQL, so whenever possible, it should just pass through user values directly to the SQL. The hard part is remembering the syntax of the specific operation, not remembering how to type \"timestamp\"!\n\n## Contributing\n\n[![GitHub repo Good Issues for newbies](https://img.shields.io/github/issues/salsita/node-pg-migrate/good%20first%20issue?style=flat\u0026logo=github\u0026logoColor=green\u0026label=Good%20First%20issues)](https://github.com/salsita/node-pg-migrate/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) [![GitHub Help Wanted issues](https://img.shields.io/github/issues/salsita/node-pg-migrate/help%20wanted?style=flat\u0026logo=github\u0026logoColor=b545d1\u0026label=%22Help%20Wanted%22%20issues)](https://github.com/salsita/node-pg-migrate/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) [![GitHub Help Wanted PRs](https://img.shields.io/github/issues-pr/salsita/node-pg-migrate/help%20wanted?style=flat\u0026logo=github\u0026logoColor=b545d1\u0026label=%22Help%20Wanted%22%20PRs)](https://github.com/salsita/node-pg-migrate/pulls?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) [![GitHub repo Issues](https://img.shields.io/github/issues/salsita/node-pg-migrate?style=flat\u0026logo=github\u0026logoColor=red\u0026label=Issues)](https://github.com/salsita/node-pg-migrate/issues?q=is%3Aopen)\n\n👋 **Welcome, new contributors!**\n\nWhether you're a seasoned developer or just getting started, your contributions are valuable to us. Don't hesitate to jump in, explore the project, and make an impact.\n\n## License\n\n[MIT](./LICENSE)\n","funding_links":[],"categories":["TypeScript","Node.js","Schema"],"sub_categories":["Changes"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalsita%2Fnode-pg-migrate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsalsita%2Fnode-pg-migrate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalsita%2Fnode-pg-migrate/lists"}