NAME
DBIO::SQLite::Diff::Rebuild - Diff operation that rebuilds a SQLite table
VERSION
version 0.900000
DESCRIPTION
SQLite's ALTER TABLE cannot change a column's type, nullability, or default in place. The only way to apply such a change is the documented rebuild dance: create a new table with the desired shape under a temporary name, copy the surviving data across, drop the original, and rename the new table into its place.
The new table is created from table_sql -- the target table's original CREATE TABLE statement as captured from sqlite_master during introspection -- with only the leading table-name token swapped for the temporary name. Reusing the captured DDL keeps the rebuild faithful: PRIMARY KEY, AUTOINCREMENT, inline foreign keys, WITHOUT ROWID, STRICT, and column defaults all survive exactly as the desired schema declared them (reconstructing them from the column model would be lossy).
copy_columns are the column names present in both the old and new table, so only those carry data over (added columns take their default, dropped columns are left behind).
The rebuild brackets itself with PRAGMA foreign_keys=OFF / ON: the statements run one at a time with autocommit on (see "_execute_ddl" in DBIO::Deploy::Base), so dropping a table that other tables reference is safe within the bracketed window.
Indexes on the rebuilt table are dropped with it; DBIO::SQLite::Diff re-emits CREATE INDEX ops for the table's target indexes after this op.
METHODS
as_sql
Returns the multi-statement rebuild SQL (semicolon-terminated statements, as expected by _split_statements).
summary
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.