{"id":22656884,"url":"https://github.com/libreworks/db-provision-pgsql","last_synced_at":"2026-02-25T11:05:54.928Z","repository":{"id":195968950,"uuid":"694288081","full_name":"libreworks/db-provision-pgsql","owner":"libreworks","description":"Provision databases and schemas in PostgreSQL along with roles, logins, and grants.","archived":false,"fork":false,"pushed_at":"2026-01-26T01:51:46.000Z","size":856,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-26T17:24:16.976Z","etag":null,"topics":["authentication","authorization","postgresql"],"latest_commit_sha":null,"homepage":"https://libreworks.github.io/db-provision-pgsql/","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/libreworks.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":null,"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":"2023-09-20T17:39:51.000Z","updated_at":"2026-01-26T01:51:47.000Z","dependencies_parsed_at":"2023-09-20T20:51:43.299Z","dependency_job_id":"0c5573a9-993e-4923-a40f-732691aa1b7d","html_url":"https://github.com/libreworks/db-provision-pgsql","commit_stats":null,"previous_names":["libreworks/db-provision-pgsql"],"tags_count":37,"template":false,"template_full_name":null,"purl":"pkg:github/libreworks/db-provision-pgsql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libreworks%2Fdb-provision-pgsql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libreworks%2Fdb-provision-pgsql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libreworks%2Fdb-provision-pgsql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libreworks%2Fdb-provision-pgsql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/libreworks","download_url":"https://codeload.github.com/libreworks/db-provision-pgsql/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libreworks%2Fdb-provision-pgsql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29819265,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T05:36:42.804Z","status":"ssl_error","status_checked_at":"2026-02-25T05:36:31.934Z","response_time":61,"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":["authentication","authorization","postgresql"],"created_at":"2024-12-09T10:16:48.584Z","updated_at":"2026-02-25T11:05:54.899Z","avatar_url":"https://github.com/libreworks.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @libreworks/db-provision-pgsql\n\n[![MIT](https://img.shields.io/github/license/libreworks/db-provision-pgsql)](https://github.com/libreworks/db-provision-pgsql/blob/main/LICENSE)\n[![npm](https://img.shields.io/npm/v/@libreworks/db-provision-pgsql)](https://www.npmjs.com/package/@libreworks/db-provision-pgsql)\n[![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/libreworks/db-provision-pgsql/release/main?label=release)](https://github.com/libreworks/db-provision-pgsql/actions/workflows/release.yml)\n[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/libreworks/db-provision-pgsql?sort=semver)](https://github.com/libreworks/db-provision-pgsql/releases)\n[![codecov](https://codecov.io/gh/libreworks/db-provision-pgsql/branch/main/graph/badge.svg?token=OHTRGNTSPO)](https://codecov.io/gh/libreworks/db-provision-pgsql)\n\nProvision databases and schemas in PostgreSQL along with roles, logins, and grants.\n\n## Installation\n\n```shell\nnpm install @libreworks/db-provision-pgsql\n```\n\nThis library conforms to ECMAScript Modules (ESM). You can import this module using ESM or TypeScript syntax.\n\n```TypeScript\nimport { Catalog } from \"@libreworks/db-provision-pgsql\";\n```\n\nIf you're using CommonJS, you must use [dynamic imports](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) instead.\n\n## Usage\n\nYou can use this library to perform initialization of a PostgreSQL database server (version 11 and later). For example, creating databases, schemas, roles, users, and grants.\n\nHere is an example to provision several database objects.\n\n```typescript\nimport { Login, Role, Catalog } from \"@libreworks/db-provision-pgsql\";\n\nconst username = \"example_user\";\nconst password = \"🙈\";\nconst owner = new Login(username, password);\n\nconst admin = new Role(\"admin\");\nconst readers = new Role(\"readers\");\n\nconst grants = [admin.assignTo(owner)];\nconst catalog = new Catalog(\"my_database\");\nconst schema = catalog.createSchema(username, owner);\ngrants.push(\n  catalog.grant(owner, \"CONNECT\", \"TEMP\"),\n  catalog.grant(readers, \"CONNECT\", \"TEMP\"),\n  schema.grant(readers, \"USAGE\"),\n  schema.allTables().grant(readers, \"SELECT\"),\n  schema.allSequences().grant(readers, \"SELECT\"),\n  schema.setDefaultTablePrivileges(readers, \"SELECT\").forCreator(owner),\n  schema.setDefaultSequencePrivileges(readers, \"SELECT\").forCreator(owner)\n);\n\n// Display the SQL\nconst statements = [\n  owner,\n  admin,\n  readers,\n  catalog,\n  schema,\n  ...grants,\n].map((v) =\u003e v.toSql());\nconsole.log(statements.join(\";\\n\") + \";\\n\");\n```\n\nThe above example outputs the following SQL statements:\n\n```sql\nCREATE USER \"example_user\" WITH PASSWORD '🙈';\nCREATE ROLE \"admin\";\nCREATE ROLE \"readers\";\nCREATE DATABASE \"my_database\" ENCODING 'UTF8';\nCREATE SCHEMA IF NOT EXISTS \"example_user\" AUTHORIZATION \"example_user\";\nGRANT \"admin\" TO \"example_user\";\nGRANT CONNECT, TEMP ON DATABASE \"my_database\" TO \"example_user\";\nGRANT CONNECT, TEMP ON DATABASE \"my_database\" TO \"readers\";\nGRANT USAGE ON SCHEMA \"example_user\" TO \"readers\";\nGRANT SELECT ON ALL TABLES IN SCHEMA \"example_user\" TO \"readers\";\nGRANT SELECT ON ALL SEQUENCES IN SCHEMA \"example_user\" TO \"readers\";\nALTER DEFAULT PRIVILEGES FOR USER \"example_user\" IN SCHEMA \"example_user\" GRANT SELECT ON TABLES TO \"readers\";\nALTER DEFAULT PRIVILEGES FOR USER \"example_user\" IN SCHEMA \"example_user\" GRANT SELECT ON SEQUENCES TO \"readers\";\n```\n\nBecause all identifiers are quoted, that means the objects will be created using the same character casing as provided. Without double quotes, PostgreSQL creates objects with lowercase identifiers.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibreworks%2Fdb-provision-pgsql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibreworks%2Fdb-provision-pgsql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibreworks%2Fdb-provision-pgsql/lists"}