Sybase/Diff.pm

filter: Statementstmt 100% 35 / 35 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 100% 43 / 43 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Shortcut/syb.pm ↑ Summary Sybase/SQLMaker.pm »
1 package DBIO::Sybase::Diff;
2 # ABSTRACT: Compare two introspected Sybase ASE models
3  
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use base 'DBIO::Diff::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9  
10 1 ▶use DBIO::Sybase::Diff::Table ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use DBIO::Sybase::Diff::Column ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use DBIO::Sybase::Diff::Index ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use DBIO::Sybase::Diff::ForeignKey ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶sub _build_operations {
Subroutine _build_operations: called CC=1 SCAR=0.0
16 1 my ($self) = @_;
17 1 my @ops;
18  
19 # Foreign keys are diffed once, then split: drops must precede table/column
20 # drops, adds must follow table/column creates. ASE FKs are not altered in
21 # place, so an attribute change is already a drop+create pair from ::ForeignKey.
22 my @fk_ops = DBIO::Sybase::Diff::ForeignKey->diff(
23 $self->source->{foreign_keys}, $self->target->{foreign_keys},
24 1 );
25 1 my @fk_drops = grep { $_->action eq 'drop' } @fk_ops;
26 1 my @fk_adds = grep { $_->action eq 'create' } @fk_ops;
27  
28 1 push @ops, @fk_drops;
29 push @ops, DBIO::Sybase::Diff::Table->diff(
30 $self->source->{tables}, $self->target->{tables},
31 $self->target->{columns}, $self->target->{foreign_keys},
32 1 );
33 push @ops, DBIO::Sybase::Diff::Column->diff(
34 $self->source->{columns}, $self->target->{columns},
35 $self->source->{tables}, $self->target->{tables},
36 1 );
37 push @ops, DBIO::Sybase::Diff::Index->diff(
38 $self->source->{indexes}, $self->target->{indexes},
39 1 );
40 1 push @ops, @fk_adds;
41  
42 1 return \@ops;
43 }
44  
45  
46 1 1;
47  
48 __END__
49  
50 =pod
51  
52 =encoding UTF-8
53  
54 =head1 NAME
55  
56 DBIO::Sybase::Diff - Compare two introspected Sybase ASE models
57  
58 =head1 VERSION
59  
60 version 0.900001
61  
62 =head1 DESCRIPTION
63  
64 C<DBIO::Sybase::Diff> compares two introspected Sybase ASE database models
65 (as produced by L<DBIO::Sybase::Introspect>) and produces a list of
66 structured diff operations that can be rendered to SQL or a human-readable
67 summary.
68  
69 my $diff = DBIO::Sybase::Diff->new(
70 source => $current_model,
71 target => $desired_model,
72 );
73  
74 if ($diff->has_changes) {
75 print $diff->as_sql;
76 print $diff->summary;
77 }
78  
79 Diff operations are generated in dependency order: foreign-key drops first
80 (so a referenced table/column can then be dropped), then tables, columns and
81 indexes, then foreign-key adds last (so the tables/columns they reference
82 already exist).
83  
84 =seealso
85  
86 =over
87  
88 =item * L<DBIO::Sybase::Deploy> - orchestrates introspection and diff
89  
90 =item * L<DBIO::Sybase::Introspect> - produces the models being compared
91  
92 =back
93  
94 =head1 AUTHOR
95  
96 DBIO & DBIx::Class Authors
97  
98 =head1 COPYRIGHT AND LICENSE
99  
100 Copyright (C) 2026 DBIO Authors
101 Portions Copyright (C) 2005-2025 DBIx::Class Authors
102 Based on DBIx::Class, heavily modified.
103  
104 This is free software; you can redistribute it and/or modify it under
105 the same terms as the Perl 5 programming language system itself.
106  
107 =cut
« Shortcut/syb.pm ↑ Summary Sybase/SQLMaker.pm »