Upgrade
Version stamps, upgrade scripts, and ALTER EXTENSION UPDATE.
Every pgmorbac install records its version in the database:
SELECT morbac.get_config('schema_version');Schema changes between versions ship as upgrade scripts named
pgmorbac--<old>--<new>.sql, included in every distribution zip alongside the
full install script for fresh databases. Each upgrade script is idempotent
and ends by bumping schema_version.
Extension installs
# copy the new release's files into the extension directory first
make installALTER EXTENSION pgmorbac UPDATE TO '0.2.0';PostgreSQL chains the upgrade scripts automatically if you skip versions.
Plain SQL installs
Apply the upgrade scripts in version order:
psql -v ON_ERROR_STOP=1 -d mydb -f pgmorbac--0.1.0--0.2.0.sqlNode.js installs
If you install through the @crudy/pgmorbac npm package, bumping the package
version brings the new upgrade scripts with it. A boot-time migration runner
applies each exactly once, in version order, tracked in
public.schema_migrations.
Safety rules
- Upgrade scripts never drop user data: organizations, roles, assignments and rules survive every upgrade.
- Verify after upgrading:
SELECT morbac.get_config('schema_version'); -- the new version
SELECT morbac.is_allowed(NULL, NULL, 'read', 'orgs'); -- engine responds (false)Downgrades are not supported; restore from backup instead.