| 1 | package DBIO::DuckDB::Diff; | ||
| 2 | # ABSTRACT: Compare two introspected DuckDB models | ||
| 3 | |||
| 4 | 4 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 4 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 4 | ▶ | use base 'DBIO::Diff::Base'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 4 | ▶ | use DBIO::DuckDB::Diff::Table; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 4 | ▶ | use DBIO::DuckDB::Diff::Column; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 4 | ▶ | use DBIO::DuckDB::Diff::Index; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | |||
| 13 | |||
| 14 | 2 | ▶ | sub _build_operations { |
|
Subroutine
_build_operations: called CC=1 SCAR=0.0
| |||
| 15 | 2 | my ($self) = @_; | |
| 16 | 2 | my @ops; | |
| 17 | |||
| 18 | push @ops, DBIO::DuckDB::Diff::Table->diff( | ||
| 19 | $self->source->{tables}, $self->target->{tables}, | ||
| 20 | $self->target->{columns}, $self->target->{foreign_keys}, | ||
| 21 | 2 | ); | |
| 22 | push @ops, DBIO::DuckDB::Diff::Column->diff( | ||
| 23 | $self->source->{columns}, $self->target->{columns}, | ||
| 24 | $self->source->{tables}, $self->target->{tables}, | ||
| 25 | 2 | ); | |
| 26 | push @ops, DBIO::DuckDB::Diff::Index->diff( | ||
| 27 | $self->source->{indexes}, $self->target->{indexes}, | ||
| 28 | $self->source->{tables}, $self->target->{tables}, | ||
| 29 | 2 | ); | |
| 30 | |||
| 31 | 2 | return \@ops; | |
| 32 | } | ||
| 33 | |||
| 34 | 4 | 1; | |
| 35 | |||
| 36 | __END__ | ||
| 37 | |||
| 38 | =pod | ||
| 39 | |||
| 40 | =encoding UTF-8 | ||
| 41 | |||
| 42 | =head1 NAME | ||
| 43 | |||
| 44 | DBIO::DuckDB::Diff - Compare two introspected DuckDB models | ||
| 45 | |||
| 46 | =head1 VERSION | ||
| 47 | |||
| 48 | version 0.900001 | ||
| 49 | |||
| 50 | =head1 DESCRIPTION | ||
| 51 | |||
| 52 | C<DBIO::DuckDB::Diff> compares two introspected DuckDB models (produced | ||
| 53 | by L<DBIO::DuckDB::Introspect>) and emits a list of structured diff | ||
| 54 | operations that can be rendered to SQL or a human-readable summary. | ||
| 55 | |||
| 56 | my $diff = DBIO::DuckDB::Diff->new( | ||
| 57 | source => $current_model, | ||
| 58 | target => $desired_model, | ||
| 59 | ); | ||
| 60 | |||
| 61 | if ($diff->has_changes) { | ||
| 62 | print $diff->as_sql; | ||
| 63 | print $diff->summary; | ||
| 64 | } | ||
| 65 | |||
| 66 | Operations are emitted in dependency order: tables, then columns, then | ||
| 67 | indexes. Drops come last for each layer. | ||
| 68 | |||
| 69 | =head1 AUTHOR | ||
| 70 | |||
| 71 | DBIO Authors | ||
| 72 | |||
| 73 | =head1 COPYRIGHT AND LICENSE | ||
| 74 | |||
| 75 | Copyright (C) 2026 DBIO Authors | ||
| 76 | |||
| 77 | This is free software; you can redistribute it and/or modify it under | ||
| 78 | the same terms as the Perl 5 programming language system itself. | ||
| 79 | |||
| 80 | =cut | ||