DBIO::DB2
IBM DB2 database driver for DBIO (fork of DBIx::Class).
Supports
- desired-state deployment via test-deploy-and-compare (DBIO::DB2::Deploy)
- native introspection via SYSCAT (DBIO::DB2::Introspect)
- native diff (DBIO::DB2::Diff)
- native DDL generation (DBIO::DB2::DDL)
Usage
package MyApp::DB;
use base 'DBIO::Schema';
__PACKAGE__->load_components('DB2');
my $schema = MyApp::DB->connect('dbi:DB2:database=myapp');
DBIO core autodetects dbi:DB2: DSNs and loads this storage automatically.
DB2 Features
Types
INTEGER,BIGINT,SMALLINT- numeric typesVARCHAR,CHAR,CLOB- string typesBLOB- binary dataDATE,TIME,TIMESTAMP- temporal typesDECIMAL- fixed-point numeric
Schema Support
- SYSCAT for introspection (tables, columns, indexes, constraints)
- Schema-qualified table references
Introspection (SYSCAT)
SYSCAT.TABLES- table metadataSYSCAT.COLUMNS- column metadataSYSCAT.INDEXES- index informationSYSCAT.TABCONST- constraints
Deploy
DBIO::DB2::Deploy orchestrates test-deploy-and-compare:
- Introspect live database via SYSCAT (DBIO::DB2::Introspect)
- Deploy desired schema to a temporary tablespace
- Introspect the temporary schema the same way
- Diff source vs target (DBIO::DB2::Diff)
Install (install_ddl) creates fresh schema. Upgrade diffs live vs. desired.
Testing
Requires a running DB2 instance:
export DBIO_TEST_DB2_DSN="dbi:DB2:database=myapp"
export DBIO_TEST_DB2_USER=db2inst1
export DBIO_TEST_DB2_PASS=secret
prove -l t/
Requirements
- Perl 5.36+
- DBD::DB2
- DBIO core
See Also
DBIO::Introspect::Base, DBIO::Diff::Base, DBIO::Deploy