PostgreSQL/Diff/Schema.pm

filter: Statementstmt 92.3% 24 / 26 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 100% 3 / 3 totaltotal 86.3% 38 / 44 CC 4 SCAR 8.5
CC
4
Cov
84%
summary
6.0
as_sql
3.0
BEGIN
1.0
CRAP 2.3
« PostgreSQL/Deploy.pm ↑ Summary PostgreSQL/Result.pm »
1 package DBIO::PostgreSQL::Diff::Schema;
2 # ABSTRACT: Diff operations for PostgreSQL schemas
3  
4 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 9 ▶use base 'DBIO::Diff::Op';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 9 ▶use DBIO::SQL::Util qw(_quote_ident);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 9 __PACKAGE__->mk_diff_accessors(qw(schema_name));
12  
13  
14  
15  
16  
17 3 ▶sub diff {
Subroutine diff: called CC=1 SCAR=0.0
Pod documented
18 3 my ($class, $source, $target) = @_;
19 return $class->diff_toplevel(
20 $source, $target,
21 1 ▶ create => sub { my ($name) = @_; $class->new(action => 'create', schema_name => $name) },
Subroutine __ANON__: called CC=1 SCAR=0.0
22 1 ▶ drop => sub { my ($name) = @_; $class->new(action => 'drop', schema_name => $name) },
Subroutine __ANON__: called CC=1 SCAR=0.0
23 3 );
24 }
25  
26  
27 2 ▶sub as_sql {
Subroutine as_sql: called CC=3 SCAR=11.0
Pod documented
28 2 my ($self) = @_;
29 2 ▶ if ($self->action eq 'create') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->action eq 'create') { } 1 1 2
elsif ($self->action eq 'drop') { } 1 0 1
30 1 return sprintf 'CREATE SCHEMA %s;',
31 _quote_ident($self->schema_name);
32 }
33 elsif ($self->action eq 'drop') {
34 1 return sprintf 'DROP SCHEMA %s CASCADE;',
35 _quote_ident($self->schema_name);
36 }
37 }
38  
39  
40 0 ▶sub summary {
Subroutine summary: not called CC=2 SCAR=17.9
Pod documented
41 0 my ($self) = @_;
42 0 ▶ return sprintf ' %sschema: %s', ($self->action eq 'create' ? '+' : '-'), $self->schema_name;
Branch: 1 branch
BranchTrueFalseTotal
$self->action eq 'create' ? : 0 0 0
43 }
44  
45 9 1;
46  
47 __END__
48  
49 =pod
50  
51 =encoding UTF-8
52  
53 =head1 NAME
54  
55 DBIO::PostgreSQL::Diff::Schema - Diff operations for PostgreSQL schemas
56  
57 =head1 VERSION
58  
59 version 0.900001
60  
61 =head1 DESCRIPTION
62  
63 Represents a single schema (namespace) diff operation: C<CREATE SCHEMA> or
64 C<DROP SCHEMA CASCADE>. Instances are produced by the L</diff> class method
65 and consumed by L<DBIO::PostgreSQL::Diff>.
66  
67 =head1 ATTRIBUTES
68  
69 =head2 schema_name
70  
71 The PostgreSQL schema name being created or dropped.
72  
73 =head2 schema_name
74  
75 The PostgreSQL schema name being created or dropped.
76  
77 =head1 METHODS
78  
79 =head2 diff
80  
81 my @ops = DBIO::PostgreSQL::Diff::Schema->diff($source, $target);
82  
83 Compares two schema hashrefs (as from L<DBIO::PostgreSQL::Introspect::Schemas>)
84 and returns a list of C<DBIO::PostgreSQL::Diff::Schema> objects representing
85 schemas to create or drop.
86  
87 =head2 as_sql
88  
89 Returns the SQL statement for this operation: C<CREATE SCHEMA name;> or
90 C<DROP SCHEMA name CASCADE;>.
91  
92 =head2 summary
93  
94 Returns a one-line human-readable description such as C<+schema: auth> or
95 C<-schema: old_ns>.
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
« PostgreSQL/Deploy.pm ↑ Summary PostgreSQL/Result.pm »