{"id":23790060,"url":"https://github.com/blackglory/pg-migrations","last_synced_at":"2026-04-12T00:44:19.867Z","repository":{"id":44955727,"uuid":"340648410","full_name":"BlackGlory/pg-migrations","owner":"BlackGlory","description":"🌿","archived":false,"fork":false,"pushed_at":"2023-12-12T12:01:30.000Z","size":237,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-04-14T09:58:18.446Z","etag":null,"topics":["library","nodejs","npm-package","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@blackglory/pg-migrations","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BlackGlory.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-20T12:23:10.000Z","updated_at":"2021-12-31T05:36:47.000Z","dependencies_parsed_at":"2025-01-01T17:18:25.968Z","dependency_job_id":"eb940cbb-fa30-4fca-bd33-aaac970099c9","html_url":"https://github.com/BlackGlory/pg-migrations","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fpg-migrations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fpg-migrations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fpg-migrations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fpg-migrations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BlackGlory","download_url":"https://codeload.github.com/BlackGlory/pg-migrations/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240018689,"owners_count":19734872,"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":["library","nodejs","npm-package","typescript"],"created_at":"2025-01-01T17:18:15.993Z","updated_at":"2026-04-12T00:44:19.858Z","avatar_url":"https://github.com/BlackGlory.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pg-migrations\nA utility for database migrations with [pg].\n\nThe module create a simple migrations table to record the schema version.\n\n[pg]: https://www.npmjs.com/package/pg\n\n## Install\n```sh\nnpm install --save @blackglory/pg-migrations\n# or\nyarn add @blackglory/pg-migrations\n```\n\n## API\n```ts\ninterface IMigration {\n  // An integer starting from 1\n  version: number\n\n  up: string | ((client: Client) =\u003e PromiseLike\u003cvoid\u003e)\n  down: string | ((client: Client) =\u003e PromiseLike\u003cvoid\u003e)\n}\n```\n\nYou may need [migration-files].\n\n[migration-files]: https://github.com/BlackGlory/migration-files\n\n### migrate\n```ts\nfunction migrate(\n  client: Client\n, migrations: IMigration[]\n, options?: {\n    targetVersion?: number\n    throwOnNewerVersion?: boolean = false\n\n    migrationsTable?: string = 'migrations'\n    advisoryLockKey?: bigint = BigInt('-9223372036854775808') // The smallest bigint for postgres\n  }\n): Promise\u003cvoid\u003e\n```\n\nIf `options.targetVersion` is `undefined`,\nthe maximum version of the `migrations` is used.\n\nWhen the maximum known migration version is less than the database schema version,\nit means the current instance is outdated.\n- When `options.throwOnNewerVersion` is `false` (default),\n  it will skip the migration,\n  so your outdated instance continues to run.\n- When `options.throwOnNewerVersion` is `true`,\n  it will throw an error,\n  so your outdated instance fails immediately.\n\n#### Can multiple instances migrate in parallel?\nYes, it uses advisory lock to ensure that only one instance is migrating at a time.\n\n#### What if my migration requires more than one connection?\nYou can get all connection configurations through properties to create a new `pg.Client`.\nIt is important to note that the custom client you create is not part of the migration transaction.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblackglory%2Fpg-migrations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblackglory%2Fpg-migrations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblackglory%2Fpg-migrations/lists"}