NAME

DBIO::MySQL::Diff - Compare two introspected MySQL/MariaDB models

VERSION

version 0.900000

DESCRIPTION

DBIO::MySQL::Diff compares two introspected MySQL/MariaDB models (as produced by DBIO::MySQL::Introspect) and produces a list of structured diff operations.

my $diff = DBIO::MySQL::Diff->new(
    source => $current_model,
    target => $desired_model,
);

if ($diff->has_changes) {
    print $diff->as_sql;
    print $diff->summary;
}

Operations are emitted in dependency order: tables, columns, indexes, foreign keys.

METHODS

target_from_compiled

my $target = DBIO::MySQL::Diff->target_from_compiled($compiled_model);

Translates the neutral model from DBIO::Schema::ModelCompiler into the MySQL/MariaDB introspect-shaped model that diff consumes.

The compiled model uses native_type (as produced by DBIO::MySQL::Adapter, e.g. BIGINT, CHAR(32), TINYINT(1)). This method maps those into the exact lowercase data_type and parameterised column_type strings that DBIO::MySQL::Introspect::Columns returns from information_schema.columns.

character_set and collation are left undef on non-text columns (numeric, binary, datetime) to match what MariaDB/MySQL reports for those types. For text and char columns the server assigns a charset/collation from the database default; since a portable schema does not prescribe a charset, those fields are also left undef in the target so the diff engine sees both sides as empty and does not emit phantom changes. See ESCALATION NOTE in the source.

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.