File Coverage

lib/DBIx/Schema/Changelog/Driver/Pg.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod n/a
total 26 26 100.0


line stmt bran cond sub pod time code
1             package DBIx::Schema::Changelog::Driver::Pg;
2              
3             =head1 NAME
4              
5             DBIx::Schema::Changelog::Driver::SQLite - The great new DBIx::Schema::Changelog::Driver::SQLite!
6              
7             =head1 VERSION
8              
9             Version 0.7.2
10              
11             =cut
12              
13             our $VERSION = '0.7.2';
14              
15 1     1   641 use strict;
  1         1  
  1         33  
16 1     1   3 use warnings;
  1         1  
  1         25  
17 1     1   733 use Moose;
  1         343922  
  1         9  
18 1     1   5159 use MooseX::HasDefaults::RO;
  1         7900  
  1         6  
19 1     1   6721 use MooseX::Types::PerlVersion qw( PerlVersion );
  1         50141  
  1         5  
20              
21             with 'DBIx::Schema::Changelog::Driver';
22              
23             has actions => (
24             isa => 'HashRef[Str]',
25             default => sub {
26             return {
27             create_table => q~CREATE TABLE {0} ( {1} ) WITH ( OIDS=FALSE )~,
28             drop_table => q~DROP TABLE {0}~,
29             alter_table => q~ALTER TABLE {0}~,
30             drop_column => q~DROP COLUMN {0}~,
31             add_column => q~ADD COLUMN {0}~,
32             create_view => 'CREATE VIEW {0} AS {1}',
33             drop_view => 'DROP VIEW {0}',
34             create_index => 'CREATE INDEX idx_{0} ON {1} USING {2} ({3})',
35             add_constraint => 'ADD {0}',
36             create_sequence =>
37             q~CREATE SEQUENCE {0} INCREMENT {1} MINVALUE {2} MAXVALUE {3} START {4} CACHE {5}~,
38             nextval_sequence => q~DEFAULT nextval('{0}'::regclass)~,
39             unique => q~CONSTRAINT {0} UNIQUE ({1})~,
40             primary => q~CONSTRAINT {0} PRIMARY KEY ({1})~,
41             foreign_key =>
42             q~CONSTRAINT {3} FOREIGN KEY ({0}) REFERENCES {1} ({2}) MATCH SIMPLE ON DELETE NO ACTION ON UPDATE NO ACTION~,
43             };
44             }
45             );
46              
47             has functions => (
48             isa => 'HashRef[Str]',
49             default => sub {
50             return {
51             add =>
52             q~CREATE FUNCTION {0}({1}) RETURNS {2} AS '{3}' LANGUAGE {4} VOLATILE COST {5}~,
53             drop => q~DROP FUNCTION {0} ({1})~,
54             };
55             }
56             );
57              
58             has constraints => (
59             isa => 'HashRef[Str]',
60             default => sub {
61             return {
62             not_null => 'NOT NULL',
63             unique => 'UNIQUE',
64             primary_key => 'PRIMARY KEY',
65             foreign_key => 'FOREIGN KEY',
66             check => 'CHECK',
67             default => 'DEFAULT',
68             };
69             }
70             );
71              
72             has defaults => (
73             isa => 'HashRef[Str]',
74             default => sub {
75             return {
76             current => 'now()',
77             inc => 'sequence',
78             not_null => 'NOT NULL',
79             primarykey => 'primary key',
80             boolean_str => 1,
81             uuid =>
82             '(md5(((((current_database())::text || ("current_user"())::text) || now()) || random())))::uuid',
83             };
84             }
85             );
86              
87             has types => (
88             isa => 'HashRef[Str]',
89             default => sub {
90             return {
91             abstime => 'abstime',
92             aclitem => 'aclitem',
93             bigint => 'bigint',
94             bigserial => 'bigserial',
95             bit => 'bit',
96             var_bit => 'bit varying',
97             bool => 'boolean',
98             box => 'box',
99             bytea => 'bytea',
100             char => '"char"',
101             character => 'character',
102             varchar => 'character varying',
103             cid => 'cid',
104             cidr => 'cidr',
105             circle => 'circle',
106             date => 'date',
107             daterange => 'daterange',
108             decimal => 'decimal',
109             double_precision => 'double precision',
110             gtsvector => 'gtsvector',
111             inet => 'inet',
112             int2vector => 'int2vector',
113             int4range => 'int4range',
114             int8range => 'int8range',
115             integer => 'integer',
116             interval => 'interval',
117             json => 'json',
118             line => 'line',
119             lseg => 'lseg',
120             macaddr => 'macaddr',
121             money => 'money',
122             name => 'name',
123             numeric => 'numeric',
124             numrange => 'numrange',
125             oid => 'oid',
126             oidvector => 'oidvector',
127             path => 'path',
128             pg_node_tree => 'pg_node_tree',
129             point => 'point',
130             polygon => 'polygon',
131             real => 'real',
132             refcursor => 'refcursor',
133             regclass => 'regclass',
134             regconfig => 'regconfig',
135             regdictionary => 'regdictionary',
136             regoper => 'regoper',
137             regoperator => 'regoperator',
138             regproc => 'regproc',
139             regprocedure => 'regprocedure',
140             regtype => 'regtype',
141             reltime => 'reltime',
142             serial => 'serial',
143             smallint => 'smallint',
144             smallserial => 'smallserial',
145             smgr => 'smgr',
146             text => 'text',
147             tid => 'tid',
148             timestamp => 'timestamp without time zone',
149             timestamp_tz => 'timestamp with time zone',
150             time => 'time without time zone',
151             time_tz => 'time with time zone',
152             tinterval => 'tinterval',
153             tsquery => 'tsquery',
154             tsrange => 'tsrange',
155             tstzrange => 'tstzrange',
156             tsvector => 'tsvector',
157             txid_snapshot => 'txid_snapshot',
158             uuid => 'uuid',
159             xid => 'xid',
160             xml => 'xml',
161             };
162             }
163             );
164              
165             has select_changelog_table => (
166             isa => 'Str',
167             lazy => 1,
168             default =>
169             "SELECT table_name FROM information_schema.tables WHERE table_schema='public'",
170             );
171              
172 1     1   24 sub _min_version { '9.1' }
173              
174 1     1   907 no Moose;
  1         1  
  1         6  
175             __PACKAGE__->meta->make_immutable;
176              
177             1;
178              
179             __END__
180              
181             =head1 AUTHOR
182              
183             Mario Zieschang, C<< <mario.zieschang at combase.de> >>
184              
185             =head1 LICENSE AND COPYRIGHT
186              
187             Copyright 2015 Mario Zieschang.
188              
189             This program is free software; you can redistribute it and/or modify it
190             under the terms of the the Artistic License (2.0). You may obtain a
191             copy of the full license at:
192              
193             L<http://www.perlfoundation.org/artistic_license_2_0>
194              
195             Any use, modification, and distribution of the Standard or Modified
196             Versions is governed by this Artistic License. By using, modifying or
197             distributing the Package, you accept this license. Do not use, modify,
198             or distribute the Package, if you do not accept this license.
199              
200             If your Modified Version has been derived from a Modified Version made
201             by someone other than you, you are nevertheless required to ensure that
202             your Modified Version complies with the requirements of this license.
203              
204             This license does not grant you the right to use any trademark, service
205             mark, trade name, or logo of the Copyright Holder.
206              
207             This license includes the non-exclusive, worldwide, free-of-charge
208             patent license to make, have made, use, offer to sell, sell, import and
209             otherwise transfer the Package with respect to any patent claims
210             licensable by the Copyright Holder that are necessarily infringed by the
211             Package. If you institute patent litigation (including a cross-claim or
212             counterclaim) against any party alleging that the Package constitutes
213             direct or contributory patent infringement, then this Artistic License
214             to you shall terminate on the date that such litigation is filed.
215              
216             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
217             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
218             THE IMPLIED WARRANTIES OF MERCHANT ABILITY, FITNESS FOR A PARTICULAR
219             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
220             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
221             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
222             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
223             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
224              
225              
226             =cut