NAME
DBIO::Deploy::Base - Base class for DBIO driver deploy orchestrators
VERSION
version 0.900000
DESCRIPTION
Base class for the per-driver Deploy orchestrators (DBIO::PostgreSQL::Deploy, DBIO::MySQL::Deploy, DBIO::DuckDB::Deploy, DBIO::SQLite::Deploy). Those classes implement the same test-deploy-and-compare strategy and their install/apply/upgrade methods were byte-near-identical; only the way diff obtains the target model (deploy the desired schema into a throwaway database and introspect it) is genuinely engine-specific.
This base hosts the shared orchestration:
"install" -- generate install DDL and run it against the live db.
"apply" -- run a diff's SQL against the live db.
"diff" -- introspect the live db (source), build the target model, and hand both to the driver's diff class.
against a handful of hooks. A subclass must provide the three class-name hooks ("_ddl_class", "_introspect_class", "_diff_class") and "_build_target_model" -- the "make a throwaway, deploy the desired schema, introspect it" step that is the real engine seam. Drivers that use a temporary database (PostgreSQL, MySQL) get a ready-made "_build_target_model" by subclassing DBIO::Deploy::Base::TempDatabase instead; in-memory drivers (DuckDB, SQLite) override "_build_target_model" directly with a :memory: connection.
ATTRIBUTES
schema
A connected DBIO::Schema instance using the driver's component. Required.
METHODS
new
my $deploy = $class->new(schema => $connected_schema, %extra);
Blesses the argument hash. schema is required.
_ddl_class
Class name whose install_ddl($schema) returns the install DDL. Abstract.
_introspect_class
Class name whose new(dbh => $dbh)->model returns an introspected model. Abstract.
_diff_class
Class name whose new(source => $m, target => $m) returns a diff object (responding to has_changes and as_sql). Abstract.
_new_introspect
my $intro = $self->_new_introspect($dbh);
Factory for an introspector over $dbh. Default: _introspect_class->new(dbh => $dbh). Override to pass extra construction args (e.g. PostgreSQL's schema_filter).
_introspect_current
The introspected model of the live (source) database. Default: $self->_new_introspect($self->_dbh)->model.
_install_ddl
The install DDL string for the connected schema. Default: _ddl_class->install_ddl($self->schema).
_execute_ddl
$self->_execute_ddl($dbh, $sql);
Splits $sql into statements ("_split_statements" in DBIO::SQL::Util) and runs each via $dbh->do, skipping comment-only statements.
_build_target_model
The desired-state model: deploy the install DDL into a throwaway database and introspect it. Abstract here -- provided by DBIO::Deploy::Base::TempDatabase for temp-database drivers, or overridden directly by in-memory drivers.
install
$deploy->install;
Generates the install DDL and executes it against the connected database. Suitable for a fresh install on an empty database. Returns true.
diff
my $diff = $deploy->diff;
Introspects the live database (source), builds the target model via "_build_target_model", and returns _diff_class->new(source => ..., target => ...).
apply
$deploy->apply($diff);
Executes each statement of $diff->as_sql against the connected database. No-op (returns false) when $diff->has_changes is false.
upgrade
my $diff = $deploy->upgrade;
Convenience: "diff" then "apply". Returns the diff object if changes were applied, or undef if the database was already up to date.
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.