NAME

DBIO::DB2::Deploy - Deploy and upgrade DB2 schemas via test-deploy-and-compare

VERSION

version 0.900000

DESCRIPTION

DBIO::DB2::Deploy orchestrates schema deployment and upgrades for DB2 using the test-deploy-and-compare strategy, parallel to DBIO::SQLite::Deploy and DBIO::PostgreSQL::Deploy.

For upgrades it:

1. Introspects the live database via SYSCAT
2. Deploys the desired schema (from DBIO classes) into a temporary schema in the same DB (DB2 requires an existing database; only a schema can be throwaway)
3. Introspects the database after deployment
4. Computes the diff between the two models using DBIO::DB2::Diff

install/diff/apply/upgrade and the dbh/schema accessors come from DBIO::Deploy::Base; this class supplies the three class-name hooks ("_ddl_class", "_introspect_class", "_diff_class"), the "_new_introspect" factory that threads a target schema into the introspector, and the genuinely DB2-specific "_build_target_model" that splices the desired schema into a throwaway CREATE SCHEMA block.

my $deploy = DBIO::DB2::Deploy->new(
    schema => MyApp::DB->connect("dbi:DB2:database=mydb"),
);
$deploy->install;                       # fresh
my $diff = $deploy->diff;              # or step-by-step
$deploy->apply($diff) if $diff->has_changes;
$deploy->upgrade;                      # convenience

METHODS

_new_introspect

my $intro = $self->_new_introspect($dbh);
my $intro = $self->_new_introspect($dbh, $schema);

Factory for the introspector. The optional $schema selects the DB2 schema to introspect (defaults to the introspector's own default, used when introspecting the live schema()).

_introspect_current

my $source_model = $self->_introspect_current;

The introspected model of the live (source) database. Overrides the DBIO::Deploy::Base default, which introspects with no schema arg and so falls back to DBIO::DB2::Introspect's USER default -- a schema DB2 connections do not actually use (e.g. db2inst1 has CURRENT SCHEMA DB2INST1), making the source model come back empty and diff/upgrade phantom-create the whole schema.

Resolves the connection's CURRENT SCHEMA (the schema where install_ddl's unqualified objects land) and threads it into the source introspector, so the high-level diff/upgrade path compares against the live objects rather than an empty model.

_build_target_model

my $target_model = $self->_build_target_model;

DB2-specific target model construction:

1. CREATE SCHEMA DBIO_TEST_<pid> in the same database
2. Re-emit the install DDL with every CREATE/DROP TABLE/INDEX statement schema-qualified to the test schema (DBIO::DB2::DDL does not auto-qualify)
3. Introspect the test schema
4. Drop the (now populated) test schema on the way out, even on failure (via "_drop_test_schema", which copes with a non-empty schema)

Returns the introspected model hashref for the test schema, suitable as the target of DBIO::DB2::Diff.

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 258:

Unknown directive: =seealso