Oracle/Diff.pm

filter: Statementstmt 86.6% 13 / 15 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 90.0% 18 / 20 CC 1 SCAR 0.6
CC
1
Cov
87%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« Oracle/Deploy.pm ↑ Summary Oracle/Introspect.pm »
1 package DBIO::Oracle::Diff;
2 # ABSTRACT: Compare two introspected Oracle models
3  
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use base 'DBIO::Diff::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9  
10 2 ▶use DBIO::Oracle::Diff::Table ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use DBIO::Oracle::Diff::Column ();
Subroutine BEGIN: called CC=1 SCAR=2.6
12 use DBIO::Oracle::Diff::Index ();
13  
14 my %_REGISTRY = (
15 tables => 'DBIO::Oracle::Diff::Table',
16 columns => 'DBIO::Oracle::Diff::Column',
17 indexes => 'DBIO::Oracle::Diff::Index',
18 );
19  
20 my @_ORDER = qw(tables columns indexes);
21  
22 my %_NEEDS_TABLES = map { $_ => 1 } qw(columns);
23  
24 sub _build_operations {
25 my ($self) = @_;
26 my @ops;
27  
28 for my $key (@_ORDER) {
29 my $diff_cls = $_REGISTRY{$key} or next;
30 next unless exists $self->source->{$key} || exists $self->target->{$key};
31  
32 my @extra;
33 if ($_NEEDS_TABLES{$key}) {
34 @extra = (
35 $self->source->{tables} // {},
36 $self->target->{tables} // {},
37 );
38 }
39  
40 push @ops, $diff_cls->diff(
41 $self->source->{$key} // {},
42 $self->target->{$key} // {},
43 @extra,
44 );
45 }
46  
47 return \@ops;
48 }
49  
50  
51 1;
52  
53 __END__
54  
55 =pod
56  
57 =encoding UTF-8
58  
59 =head1 NAME
60  
61 DBIO::Oracle::Diff - Compare two introspected Oracle models
62  
63 =head1 VERSION
64  
65 version 0.900001
66  
67 =head1 DESCRIPTION
68  
69 C<DBIO::Oracle::Diff> compares two introspected Oracle database models
70 (as produced by L<DBIO::Oracle::Introspect>) and produces a list of
71 structured diff operations. These operations can then be rendered to SQL
72 or a human-readable summary.
73  
74 my $diff = DBIO::Oracle::Diff->new(
75 source => $current_model,
76 target => $desired_model,
77 );
78  
79 if ($diff->has_changes) {
80 print $diff->as_sql;
81 print $diff->summary;
82 }
83  
84 Diff operations are generated in dependency order: tables first, then
85 columns, then indexes. Drops come last.
86  
87 =seealso
88  
89 =over 4
90  
91 =item * L<DBIO::Oracle::Deploy> - orchestrates introspection and diff
92  
93 =item * L<DBIO::Oracle::Introspect> - produces the models being compared
94  
95 =back
96  
97 =head1 AUTHOR
98  
99 DBIO & DBIx::Class Authors
100  
101 =head1 COPYRIGHT AND LICENSE
102  
103 Copyright (C) 2026 DBIO Authors
104 Portions Copyright (C) 2005-2025 DBIx::Class Authors
105 Based on DBIx::Class, heavily modified.
106  
107 This is free software; you can redistribute it and/or modify it under
108 the same terms as the Perl 5 programming language system itself.
109  
110 =cut
« Oracle/Deploy.pm ↑ Summary Oracle/Introspect.pm »