DBIO-PostgreSQL
view release on metacpan or search on metacpan
lib/DBIO/PostgreSQL/Result.pm view on Meta::CPAN
=head2 pg_indexes
my $all = $class->pg_indexes; # hashref of name => def
Returns a copy of all index definitions registered on this result class.
=head2 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 C<when> (C<BEFORE>/C<AFTER>/C<INSTEAD OF>), C<event>
(C<INSERT>/C<UPDATE>/C<DELETE>/C<TRUNCATE>), and C<execute> (the function to
call).
=head2 pg_triggers
my $all = $class->pg_triggers; # hashref of name => def
Returns a copy of all trigger definitions registered on this result class.
=head2 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:
=over 4
=item C<enable> - boolean, generates C<ENABLE ROW LEVEL SECURITY>
=item C<force> - boolean, generates C<FORCE ROW LEVEL SECURITY>
=item C<policies> - hashref of policy name to policy definition (C<for>, C<using>, C<with_check>)
=back
=head2 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 C<constraint_name>,
C<definition> (which may already include C<CHECK>), and optional C<columns>.
=head2 pg_check_constraints
my $all = $class->pg_check_constraints;
Returns a copy of all CHECK constraint definitions registered on this result class.
=head2 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 C<belongs_to>. Each call appends; arrayrefs are flattened.
=seealso
=over 4
=item * L<DBIO::PostgreSQL> - the schema component (Database layer)
=item * L<DBIO::PostgreSQL::PgSchema> - the PgSchema layer for enums, types, functions
=item * L<DBIO::PostgreSQL::DDL> - generates DDL from result class metadata
=back
=head1 AUTHOR
DBIO & DBIx::Class Authors
=head1 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.
=cut
( run in 1.695 second using v1.01-cache-2.11-cpan-800906f7e73 )