~ubuntu-branches/ubuntu/wily/libdbix-class-deploymenthandler-perl/wily-proposed

« back to all changes in this revision

Viewing changes to README

  • Committer: Package Import Robot
  • Author(s): gregor herrmann
  • Date: 2015-06-28 15:48:07 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20150628154807-1sd0rkhxi689792r
Tags: 0.002216-1
* Team upload.
* Import upstream version 0.002216.
* Update years of upstream copyright.
* Refresh lintian override (changed lone number).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
NAME
2
 
    DBIx::Class::DeploymentHandler - Extensible DBIx::Class deployment
3
 
 
4
1
SYNOPSIS
 
2
 
5
3
     use aliased 'DBIx::Class::DeploymentHandler' => 'DH';
6
4
     my $s = My::Schema->connect(...);
7
 
 
 
5
    
8
6
     my $dh = DH->new({
9
7
       schema              => $s,
10
8
       databases           => 'SQLite',
11
9
       sql_translator_args => { add_drop_table => 0 },
12
10
     });
13
 
 
 
11
    
14
12
     $dh->prepare_install;
15
 
 
 
13
    
16
14
     $dh->install;
17
15
 
18
16
    or for upgrades:
19
17
 
20
18
     use aliased 'DBIx::Class::DeploymentHandler' => 'DH';
21
19
     my $s = My::Schema->connect(...);
22
 
 
 
20
    
23
21
     my $dh = DH->new({
24
22
       schema              => $s,
25
23
       databases           => 'SQLite',
26
24
       sql_translator_args => { add_drop_table => 0 },
27
25
     });
28
 
 
 
26
    
 
27
     $dh->prepare_deploy;
29
28
     $dh->prepare_upgrade({
30
29
       from_version => 1,
31
30
       to_version   => 2,
32
31
     });
33
 
 
 
32
    
34
33
     $dh->upgrade;
35
34
 
36
35
DESCRIPTION
37
 
    "DBIx::Class::DeploymentHandler" is, as its name suggests, a tool for
38
 
    deploying and upgrading databases with DBIx::Class. It is designed to be
39
 
    much more flexible than DBIx::Class::Schema::Versioned, hence the use of
40
 
    Moose and lots of roles.
41
 
 
42
 
    "DBIx::Class::DeploymentHandler" itself is just a recommended set of
 
36
 
 
37
    DBIx::Class::DeploymentHandler is, as its name suggests, a tool for
 
38
    deploying and upgrading databases with DBIx::Class. It is designed to
 
39
    be much more flexible than DBIx::Class::Schema::Versioned, hence the
 
40
    use of Moose and lots of roles.
 
41
 
 
42
    DBIx::Class::DeploymentHandler itself is just a recommended set of
43
43
    roles that we think will not only work well for everyone, but will also
44
44
    yield the best overall mileage. Each role it uses has its own nuances
45
45
    and documentation, so I won't describe all of them here, but here are a
46
 
    few of the major benefits over how DBIx::Class::Schema::Versioned worked
47
 
    (and DBIx::Class::DeploymentHandler::Deprecated tries to maintain
48
 
    compatibility with):
49
 
 
50
 
    *   Downgrades in addition to upgrades.
51
 
 
52
 
    *   Multiple sql files files per upgrade/downgrade/install.
53
 
 
54
 
    *   Perl scripts allowed for upgrade/downgrade/install.
55
 
 
56
 
    *   Just one set of files needed for upgrade, unlike before where one
57
 
        might need to generate "factorial(scalar @versions)", which is just
58
 
        silly.
59
 
 
60
 
    *   And much, much more!
 
46
    few of the major benefits over how DBIx::Class::Schema::Versioned
 
47
    worked (and DBIx::Class::DeploymentHandler::Deprecated tries to
 
48
    maintain compatibility with):
 
49
 
 
50
      * Downgrades in addition to upgrades.
 
51
 
 
52
      * Multiple sql files files per upgrade/downgrade/install.
 
53
 
 
54
      * Perl scripts allowed for upgrade/downgrade/install.
 
55
 
 
56
      * Just one set of files needed for upgrade, unlike before where one
 
57
      might need to generate factorial(scalar @versions), which is just
 
58
      silly.
 
59
 
 
60
      * And much, much more!
61
61
 
62
62
    That's really just a taste of some of the differences. Check out each
63
63
    role for all the details.
64
64
 
65
65
WHERE IS ALL THE DOC?!
66
 
    "DBIx::Class::DeploymentHandler" extends
 
66
 
 
67
    DBIx::Class::DeploymentHandler extends
67
68
    DBIx::Class::DeploymentHandler::Dad, so that's probably the first place
68
69
    to look when you are trying to figure out how everything works.
69
70
 
74
75
    DBIx::Class::DeploymentHandler::VersionStorage::Standard, and
75
76
    DBIx::Class::DeploymentHandler::WithReasonableDefaults.
76
77
 
 
78
     $dh->prepare_version_storage_install
 
79
 
 
80
    Creates the needed .sql file to install the version storage and not the
 
81
    rest of the tables
 
82
 
 
83
     $dh->prepare_install
 
84
 
 
85
    First prepare all the tables to be installed and the prepare just the
 
86
    version storage
 
87
 
 
88
     $dh->install_version_storage
 
89
 
 
90
    Install the version storage and not the rest of the tables
 
91
 
77
92
WHY IS THIS SO WEIRD
78
 
    "DBIx::Class::DeploymentHandler" has a strange structure. The gist is
 
93
 
 
94
    DBIx::Class::DeploymentHandler has a strange structure. The gist is
79
95
    that it delegates to three small objects that are proxied to via
80
96
    interface roles that then create the illusion of one large, monolithic
81
97
    object. Here is a diagram that might help:
82
98
 
83
 
                        +------------+
84
 
                        |            |
85
 
           +------------+ Deployment +-----------+
86
 
           |            |  Handler   |           |
87
 
           |            |            |           |
88
 
           |            +-----+------+           |
89
 
           |                  |                  |
90
 
           |                  |                  |
91
 
           :                  :                  :
92
 
           v                  v                  v
93
 
      /-=-------\        /-=-------\       /-=----------\
94
 
      |         |        |         |       |            |  (interface roles)
95
 
      | Handles |        | Handles |       |  Handles   |
96
 
      | Version |        | Deploy  |       | Versioning |
97
 
      | Storage |        |         |       |            |
98
 
      |         |        \-+--+--+-/       \-+---+---+--/
99
 
      \-+--+--+-/          |  |  |           |   |   |
100
 
        |  |  |            |  |  |           |   |   |
101
 
        |  |  |            |  |  |           |   |   |
102
 
        v  v  v            v  v  v           v   v   v
103
 
     +----------+        +--------+        +-----------+
104
 
     |          |        |        |        |           |  (implementations)
105
 
     | Version  |        | Deploy |        |  Version  |
106
 
     | Storage  |        | Method |        |  Handler  |
107
 
     | Standard |        | SQLT   |        | Monotonic |
108
 
     |          |        |        |        |           |
109
 
     +----------+        +--------+        +-----------+
110
 
 
111
99
    The nice thing about this is that we have well defined interfaces for
112
 
    the objects that comprise the "DeploymentHandler", the smaller objects
 
100
    the objects that comprise the DeploymentHandler, the smaller objects
113
101
    can be tested in isolation, and the smaller objects can even be swapped
114
102
    in easily. But the real win is that you can subclass the
115
 
    "DeploymentHandler" without knowing about the underlying delegation; you
 
103
    DeploymentHandler without knowing about the underlying delegation; you
116
104
    just treat it like normal Perl and write methods that do what you want.
117
105
 
118
106
THIS SUCKS
 
107
 
119
108
    You started your project and weren't using
120
 
    "DBIx::Class::DeploymentHandler"? Lucky for you I had you in mind when I
 
109
    DBIx::Class::DeploymentHandler? Lucky for you I had you in mind when I
121
110
    wrote this doc.
122
111
 
123
112
    First, define the version in your main schema file (maybe using
127
116
 
128
117
     my $s = My::Schema->connect(...);
129
118
     my $dh = DBIx::Class::DeploymentHandler->new({ schema => $s });
130
 
 
 
119
    
131
120
     $dh->prepare_version_storage_install;
132
121
     $dh->install_version_storage;
133
122
 
135
124
 
136
125
     $dh->add_database_version({ version => $s->schema_version });
137
126
 
138
 
    Now you should be able to use "DBIx::Class::DeploymentHandler" like
 
127
    Now you should be able to use DBIx::Class::DeploymentHandler like
139
128
    normal!
140
129
 
141
130
LOGGING
142
 
    This is a complex tool, and because of that sometimes you'll want to see
143
 
    what exactly is happening. The best way to do that is to use the built
144
 
    in logging functionality. It the standard six log levels; "fatal",
145
 
    "error", "warn", "info", "debug", and "trace". Most of those are pretty
146
 
    self explanatory. Generally a safe level to see what all is going on is
 
131
 
 
132
    This is a complex tool, and because of that sometimes you'll want to
 
133
    see what exactly is happening. The best way to do that is to use the
 
134
    built in logging functionality. It the standard six log levels; fatal,
 
135
    error, warn, info, debug, and trace. Most of those are pretty self
 
136
    explanatory. Generally a safe level to see what all is going on is
147
137
    debug, which will give you everything except for the exact SQL being
148
138
    run.
149
139
 
150
140
    To enable the various logging levels all you need to do is set an
151
 
    environment variables: "DBICDH_FATAL", "DBICDH_ERROR", "DBICDH_WARN",
152
 
    "DBICDH_INFO", "DBICDH_DEBUG", and "DBICDH_TRACE". Each level can be set
153
 
    on its own, but the default is the first three on and the last three
154
 
    off, and the levels cascade, so if you turn on trace the rest will turn
155
 
    on automatically.
 
141
    environment variables: DBICDH_FATAL, DBICDH_ERROR, DBICDH_WARN,
 
142
    DBICDH_INFO, DBICDH_DEBUG, and DBICDH_TRACE. Each level can be set on
 
143
    its own, but the default is the first three on and the last three off,
 
144
    and the levels cascade, so if you turn on trace the rest will turn on
 
145
    automatically.
156
146
 
157
147
DONATIONS
 
148
 
158
149
    If you'd like to thank me for the work I've done on this module, don't
159
150
    give me a donation. I spend a lot of free time creating free software,
160
151
    but I do it because I love it.
162
153
    Instead, consider donating to someone who might actually need it.
163
154
    Obviously you should do research when donating to a charity, so don't
164
155
    just take my word on this. I like Matthew 25: Ministries:
165
 
    <http://www.m25m.org/>, but there are a host of other charities that can
166
 
    do much more good than I will with your money. (Third party charity info
167
 
    here:
168
 
    <http://www.charitynavigator.org/index.cfm?bay=search.summary&orgid=6901
169
 
    >
170
 
 
171
 
METHODS
172
 
  prepare_version_storage_install
173
 
     $dh->prepare_version_storage_install
174
 
 
175
 
    Creates the needed ".sql" file to install the version storage and not
176
 
    the rest of the tables
177
 
 
178
 
  prepare_install
179
 
     $dh->prepare_install
180
 
 
181
 
    First prepare all the tables to be installed and the prepare just the
182
 
    version storage
183
 
 
184
 
  install_version_storage
185
 
     $dh->install_version_storage
186
 
 
187
 
    Install the version storage and not the rest of the tables
188
 
 
189
 
AUTHOR
190
 
    Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
191
 
 
192
 
COPYRIGHT AND LICENSE
193
 
    This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
194
 
 
195
 
    This is free software; you can redistribute it and/or modify it under
196
 
    the same terms as the Perl 5 programming language system itself.
 
156
    http://www.m25m.org/, but there are a host of other charities that can
 
157
    do much more good than I will with your money. (Third party charity
 
158
    info here:
 
159
    http://www.charitynavigator.org/index.cfm?bay=search.summary&orgid=6901
 
160
 
 
161
POD ERRORS
 
162
 
 
163
    Hey! The above document had some coding errors, which are explained
 
164
    below:
 
165
 
 
166
    Around line 91:
 
167
 
 
168
      Unknown directive: =method
 
169
 
 
170
    Around line 98:
 
171
 
 
172
      Unknown directive: =method
 
173
 
 
174
    Around line 105:
 
175
 
 
176
      Unknown directive: =method
197
177