NAME

DBIO::PostgreSQL::Result - PostgreSQL-specific Result component for DBIO

VERSION

version 0.900000

DESCRIPTION

DBIO::PostgreSQL::Result is a DBIO Result component that adds PostgreSQL-native metadata to a result class: the PostgreSQL schema (namespace) the table belongs to, custom indexes, triggers, and Row Level Security (RLS) configuration.

Load it with:

package MyApp::DB::Result::User;
use base 'DBIO::Core';
__PACKAGE__->load_components('PostgreSQL::Result');

__PACKAGE__->pg_schema('auth');
__PACKAGE__->table('users');

The schema name from pg_schema is used by DBIO::PostgreSQL::DDL to qualify table names (e.g. auth.users) in generated DDL.

METHODS

pg_schema

__PACKAGE__->pg_schema('auth');
my $name = $class->pg_schema;

Get or set the PostgreSQL schema (namespace) for this result class. When set, DBIO::PostgreSQL::DDL qualifies the table name as schema.table in generated DDL.

pg_qualified_table

my $fqn = $class->pg_qualified_table;  # e.g. 'auth.users'

Returns the fully-qualified table name schema.table, or just table if no PostgreSQL schema has been set.

pg_index

__PACKAGE__->pg_index('idx_users_tags' => {
    using   => 'gin',
    columns => ['tags'],
});
__PACKAGE__->pg_index('idx_users_active' => {
    columns => ['role'],
    where   => "role != 'suspended'",
});
__PACKAGE__->pg_index('idx_users_embedding' => {
    using   => 'ivfflat',
    columns => ['embedding'],
    with    => { lists => 100 },
});

my $def = $class->pg_index('idx_users_tags');

Get or set the definition for a named PostgreSQL index. The definition hashref accepts:

columns - ArrayRef of column names
using - index access method (btree, gin, gist, brin, hash, ivfflat, etc.)
where - partial index predicate (SQL expression string)
expression - expression index expression (replaces columns)
with - storage parameter hashref (e.g. { lists => 100 } for ivfflat)

pg_indexes

my $all = $class->pg_indexes;  # hashref of name => def

Returns a copy of all index definitions registered on this result class.

pg_trigger

__PACKAGE__->pg_trigger('users_modified_at' => {
    when    => 'BEFORE',
    event   => 'UPDATE',
    execute => 'auth.update_modified_at()',
});

my $def = $class->pg_trigger('users_modified_at');

Get or set the definition for a named PostgreSQL trigger. The definition hashref accepts when (BEFORE/AFTER/INSTEAD OF), event (INSERT/UPDATE/DELETE/TRUNCATE), and execute (the function to call).

pg_triggers

my $all = $class->pg_triggers;  # hashref of name => def

Returns a copy of all trigger definitions registered on this result class.

pg_rls

__PACKAGE__->pg_rls({
    enable   => 1,
    force    => 1,
    policies => {
        users_own_data => {
            for   => 'ALL',
            using => 'id = current_setting($$app.current_user_id$$)::uuid',
        },
    },
});

my $rls = $class->pg_rls;

Get or set the Row Level Security configuration for this table. The hashref accepts:

enable - boolean, generates ENABLE ROW LEVEL SECURITY
force - boolean, generates FORCE ROW LEVEL SECURITY
policies - hashref of policy name to policy definition (for, using, with_check)

pg_check_constraint

__PACKAGE__->pg_check_constraint('run_status_invariant' =>
  "(status IN ('Pending','Running','Done') AND error IS NULL)"
  . " OR status IN ('Blocked','Failed','Cancelled')"
);
__PACKAGE__->pg_check_constraint('idx_name' => {
  constraint_name => 'idx_name',
  definition      => 'CHECK (col > 0)',
  columns         => ['col'],
});

my $def = $class->pg_check_constraint('run_status_invariant');

Get or set a named CHECK constraint. Accepts either a plain string (the CHECK predicate expression) or a hashref with constraint_name, definition (which may already include CHECK), and optional columns.

pg_check_constraints

my $all = $class->pg_check_constraints;

Returns a copy of all CHECK constraint definitions registered on this result class.

pg_extra_ddl

__PACKAGE__->pg_extra_ddl(
  'ALTER TABLE goldmine_site ADD CONSTRAINT goldmine_site_paypal_account_id_fkey'
  . ' FOREIGN KEY (paypal_account_id) REFERENCES goldmine_paypal_account (id)'
  . ' ON DELETE RESTRICT',
);

Appends raw SQL statements to be emitted after the table, indexes, triggers, and RLS DDL. Used for cross-table FKs that DBIO::PostgreSQL::DDL does not auto-generate from belongs_to. Each call appends; arrayrefs are flattened.

AUTHOR

DBIO & DBIx::Class Authors

COPYRIGHT AND LICENSE

Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 287:

Unknown directive: =seealso