pgmorbacMulti-OrBAC for PostgreSQL
    DocumentationDownloadSource
    Use cases
    • How do I...?
    Getting Started
    • Introduction
    • Quick start
    • How pgmorbac compares
    • Upgrade
    Concepts
    • Organizations
    • Roles
    • Activities
    • Views
    • Contexts
    • Rules & Modalities
    • Global Rules
    • System Principals
    • Constraints
    • Row-Level Security
    • Decision Cache
    Resolution
    • is_allowed
    Recipes
    • Org Hierarchies
    • Multi-Tenant Isolation
    • Wildcard Admin
    • Delegation
    • Service Accounts
    • Deny Rules
    • Separation of Duty
    • Derived Roles
    • Cross-Org Access
    • Obligations & Recommendations
    • Temporal Access
    Integration
    • Fastify
    • PostgREST & RLS Context
    • SQL Only
    Reference
    • Function Reference
    Getting Started

    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 install
    ALTER 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.sql

    Node.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.

    PreviousHow pgmorbac comparesNext Organizations
    pgmorbac - Multi-OrBAC permission engine for PostgreSQL
    DocumentationDownloadGitea