NAME

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

VERSION

version 0.900000

DESCRIPTION

DBIO::SQLite::Deploy orchestrates the deployment and upgrade of SQLite schemas using a test-deploy-and-compare strategy.

For upgrades, instead of computing diffs from abstract class representations, it:

1. Introspects the live database via sqlite_master and PRAGMAs
2. Connects to a fresh in-memory SQLite database
3. Deploys the desired schema (from DBIO classes) into the in-memory DB
4. Introspects the in-memory database the same way
5. Computes the diff between the two models using DBIO::SQLite::Diff

The temp DB is in-memory and goes away when the connection drops -- much simpler than the temp-database approach used for PostgreSQL.

The orchestration (install, apply, upgrade) and the diff shell come from DBIO::Deploy::Base; only the engine-specific target-model build is overridden here.

my $deploy = DBIO::SQLite::Deploy->new(
    schema => MyApp::DB->connect("dbi:SQLite:dbname=app.db"),
);

# Fresh install
$deploy->install;

# Upgrade
$deploy->upgrade;

# Or in steps:
my $diff = $deploy->diff;
print $diff->summary;
$deploy->apply($diff) if $diff->has_changes;

METHODS

_build_target_model

Connect to a throwaway in-memory SQLite database, deploy the desired schema into it, and return its introspected model. The in-memory connection goes out of scope at the end of this method (and is disconnected explicitly for predictability), so the target DB is gone before the diff object is built.

apply

Apply the diff, then -- if it contained a table rebuild -- verify cross-table foreign-key integrity. A rebuild runs with PRAGMA foreign_keys=OFF so it can drop and rename a referenced table; once it is back in place this runs PRAGMA foreign_key_check and throws if any dangling references remain. Non-rebuild upgrades are untouched (no extra check).

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.