NAME
DBIO::PostgreSQL - PostgreSQL-specific schema management for DBIO
VERSION
version 0.900000
SYNOPSIS
Schema class
package MyApp::Schema;
use DBIO 'Schema';
__PACKAGE__->load_components('PostgreSQL');
__PACKAGE__->pg_schemas(qw( public auth ));
Or use the -pg shortcut, which pins +DBIO::PostgreSQL::Storage as the storage type directly:
package MyApp::Schema;
use DBIO Schema => -pg;
Result classes
package MyApp::Schema::Result::Artist;
use DBIO;
__PACKAGE__->table('artist');
__PACKAGE__->add_columns(
id => { data_type => 'integer', is_auto_increment => 1 },
name => { data_type => 'varchar', size => 100 },
);
__PACKAGE__->set_primary_key('id');
For result classes with PostgreSQL-native features, use -pg to load DBIO::PostgreSQL::Result:
package MyApp::Schema::Result::User;
use DBIO -pg;
__PACKAGE__->pg_schema('auth');
__PACKAGE__->table('users');
__PACKAGE__->add_columns(
id => { data_type => 'uuid', default_value => \'gen_random_uuid()' },
name => { data_type => 'varchar', size => 100 },
tags => { data_type => 'text[]' },
);
__PACKAGE__->set_primary_key('id');
__PACKAGE__->pg_index('idx_users_name' => { columns => ['name'] });
__PACKAGE__->pg_index('idx_users_tags' => { using => 'gin', columns => ['tags'] });
Connecting
my $schema = MyApp::Schema->connect($dsn, $user, $pass);
The classic use base form is still supported:
package MyApp::Schema;
use base 'DBIO::Schema';
__PACKAGE__->load_components('PostgreSQL');
DESCRIPTION
DBIO::PostgreSQL is the PostgreSQL driver component for DBIO.
When this component is loaded into a schema class, connection() sets "storage_type" in DBIO::Schema to +DBIO::PostgreSQL::Storage, which enables PostgreSQL-specific storage behavior automatically.
This distribution also provides PostgreSQL-native DDL/deploy helpers and introspection/diff tooling.
METHODS
pg_schemas
Get or set the list of PostgreSQL schema names tracked by this schema class.
pg_schema_class
Get or set the class mapped to a specific PostgreSQL schema name.
pg_extensions
Get or set PostgreSQL extensions to include during deploy/DDL operations.
pg_search_path
Get or set the default PostgreSQL search_path list.
pg_settings
Get or set additional PostgreSQL settings stored on the schema class.
connection
Overrides "connection" in DBIO to force +DBIO::PostgreSQL::Storage as storage_type.
pg_deploy
Returns a DBIO::PostgreSQL::Deploy instance for the schema.
pg_install_ddl
Generates PostgreSQL-native DDL statements for the schema.
MIGRATION NOTES
The PostgreSQL storage class was split out of the historical DBIx::Class monolithic distribution:
Old:
DBIx::Class::Storage::DBI::PgNew:
DBIO::PostgreSQL::Storage
If DBIO-PostgreSQL is installed, core DBIO::Storage::DBI can autodetect PostgreSQL DSNs and load the new storage class via the driver registry.
TESTING
Integration tests in this distribution use:
DBIO_TEST_PG_DSN
DBIO_TEST_PG_USER
DBIO_TEST_PG_PASS
SQLMaker-focused tests can run offline via DBIO::Test with:
storage_type => 'DBIO::PostgreSQL::Storage'
Replicated-path tests can reuse the same harness with:
replicated => 1,
storage_type => 'DBIO::PostgreSQL::Storage'
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.