feat: npm package @crudy/pgmorbac ships the extension SQL

The package carries the install and upgrade scripts, built from src/ on prepack
(sql/ is not committed), with extensionSql(), upgradeScripts(), version and sqlDir.
This commit is contained in:
2026-10-02 23:59:58 +02:00
parent 697e8bd682
commit 8385cea640
7 changed files with 141 additions and 3 deletions
+18
View File
@@ -77,6 +77,24 @@ sudo cp pgmorbac--1.0.0.sql $(pg_config --sharedir)/extension/
psql -d mydb -c "CREATE EXTENSION pgmorbac;"
```
### From Node.js (npm)
`@crudy/pgmorbac` ships the same install and upgrade scripts for projects that
apply SQL through a migration runner instead of `CREATE EXTENSION`:
```bash
npm install @crudy/pgmorbac
```
```js
import { extensionSql, upgradeScripts, version, sqlDir } from '@crudy/pgmorbac';
await client.query(extensionSql()); // pgmorbac--<version>.sql
for (const u of upgradeScripts()) { // pgmorbac--<from>--<to>.sql, in order
await client.query(u.sql);
}
```
## Quick Start
```sql