This file is indexed.

/usr/share/perl5/DBIx/Class/DeploymentHandler/Manual/CatalystIntro.pod is in libdbix-class-deploymenthandler-perl 0.002208-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
package DBIx::Class::DeploymentHandler::Manual::CatalystIntro

# ABSTRACT: Introduction to using DBIx::Class::DeploymentHandler with a new Catalyst Project

__END__

=pod

=head1 NAME

DBIx::Class::DeploymentHandler::Manual::CatalystIntro - Introduction to using DBIx::Class::DeploymentHandler with a new Catalyst Project

=head1 Background

This introduction will use PostgreSQL and L<Catalyst>.  Background
information on using PostgreSQL with Catalyst can be found at
L<Catalyst::Manual::Tutorial::10_Appendices>.  This guide will assume that
you have some understanding of Catalyst.  Please go through the Catalyst
tutorials first if you have not yet done so.

=head1 Database Setup

Start by creating a user C<catalyst>, with password C<catalyst>

 $ sudo -u postgres createuser -P catalyst
 Enter password for new role: <catalyst>
 Enter it again: <catalyst>
 Shall the new role be a superuser? (y/n) n
 Shall the new role be allowed to create databases? (y/n) n
 Shall the new role be allowed to create more new roles? (y/n) n

Then create a new database called C<deploymentintro>

 sudo -u postgres createdb -O catalyst deploymentintro

=head1 Create the project

 $ catalyst.pl DeploymentIntro
 $ cd DeploymentIntro
 $ perl Makefile.PL

=head1 Create the Schema

 $ script/deploymentintro_create.pl model DB DBIC::Schema DeploymentIntro::Schema \
     create=static 'dbi:Pg:dbname=deploymentintro' 'catalyst' 'catalyst' '{ AutoCommit => 1 }'

 $ mkdir -p lib/Schema/Result

Remove the following from C<lib/DeploymentIntro/Model/DB.pm>:

 connect_info => {
   dsn => 'dbi:Pg:dbname=deploymentintro',
   user => 'catalyst',
   password => 'catalyst',
   AutoCommit => q{1},
 }

Remove C<deploymentintro.conf> and create a new file called
C<deploymentintro_local.pl> with the following:

    {
        name => "DeploymentIntro",

        "Model::DB" => {
            schema_class => 'DeploymentIntro::Schema',

            connect_info => {
                dsn        => 'dbi:Pg:dbname=deploymentintro',
                user       => 'catalyst',
                password   => 'catalyst',
                AutoCommit => 1,
            }
        }
    }

Copy the following program into scripts, under the name
C<deploymentintro_dbicdh.pl>

 #!/usr/bin/env perl

 use strict;
 use warnings;

 use feature ":5.10";

 use aliased 'DBIx::Class::DeploymentHandler' => 'DH';
 use FindBin;
 use lib "$FindBin::Bin/../lib";
 use DeploymentIntro::Schema;
 use Config::JFDI;

 my $config = Config::JFDI->new( name => 'DeploymentIntro' );
 my $config_hash  = $config->get;
 my $connect_info = $config_hash->{"Model::DB"}{"connect_info"};
 my $schema       = DeploymentIntro::Schema->connect($connect_info);

 my $dh = DH->new({
   schema           => $schema,
   script_directory => "$FindBin::Bin/../dbicdh",
   databases        => 'PostgreSQL',
 });

 sub install {
   $dh->prepare_install;
   $dh->install;
 }

 sub upgrade {
   die "Please update the version in Schema.pm"
     if ( $dh->version_storage->version_rs->search({version => $dh->schema_version})->count );

   die "We only support positive integers for versions around these parts."
     unless $dh->schema_version =~ /^\d+$/;

   $dh->prepare_deploy;
   $dh->prepare_upgrade;
   $dh->upgrade;
 }

 sub current_version {
   say $dh->database_version;
 }

 sub help {
 say <<'OUT';
 usage:
   install
   upgrade
   current-version
 OUT
 }

 help unless $ARGV[0];

 given ( $ARGV[0] ) {
     when ('install')         { install()         }
     when ('upgrade')         { upgrade()         }
     when ('current-version') { current_version() }
 }

Copy the following files into C<lib/DeploymentIntro/Schema/Result>:

C<Cd.pm>

 package DeploymentIntro::Schema::Result::Cd;

 use strict;
 use warnings;

 use parent 'DBIx::Class::Core';

 __PACKAGE__->load_components(qw(InflateColumn::DateTime));
 __PACKAGE__->table('cd');

 __PACKAGE__->add_columns(
   id => {
     data_type => 'integer',
     is_auto_increment => 1,
   },
   artist_id => {
     data_type => 'integer'
   },
   title => {
     data_type => 'text'
   },
 );

 __PACKAGE__->set_primary_key('id');

 __PACKAGE__->belongs_to(
   artist => 'DeploymentIntro::Schema::Result::Artist', 'artist_id' );

 __PACKAGE__->has_many(
   tracks => 'DeploymentIntro::Schema::Result::Track', 'cd_id' );

 1;

C<Artist.pm>

 package DeploymentIntro::Schema::Result::Artist;

 use strict;
 use warnings;

 use parent 'DBIx::Class::Core';

 __PACKAGE__->table('artist');

 __PACKAGE__->add_columns(
   id => {
     data_type => 'integer',
     is_auto_increment => 1,
   },
   name => {
     data_type => 'text'
   },
 );

 __PACKAGE__->set_primary_key('id');

 __PACKAGE__->has_many(
   cds => 'DeploymentIntro::Schema::Result::Cd', 'artist_id' );

 1;

C<Track.pm>

 package DeploymentIntro::Schema::Result::Track;

 use strict;
 use warnings;

 use parent 'DBIx::Class::Core';

 __PACKAGE__->table('track');

 __PACKAGE__->add_columns(
   id => {
     data_type => 'integer',
     is_auto_increment => 1,
   },
   cd_id => {
     data_type => 'integer',
   },
   title => {
     data_type => 'text',
   }
 );

 __PACKAGE__->set_primary_key('id');

 __PACKAGE__->belongs_to(
   cd => 'DeploymentIntro::Schema::Result::Cd', 'cd_id' );

 1;

And then edit C<lib/DeploymentIntro/Schema.pm> and add the following above the
1 at the bottom

 our $VERSION = 1;

Now it is just a matter of running

 ./script/deploymentintro_dbicdh.pl install

=head1 AUTHOR

Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Arthur Axel "fREW" Schmidt.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut