1DBIx::Class::Schema::LoUasdeerr:C:oBnatsrei(b3u)ted PerlDBDIoxc:u:mCelnatsast:i:oSnchema::Loader::Base(3)
2
3
4
6 DBIx::Class::Schema::Loader::Base - Base DBIx::Class::Schema::Loader
7 Implementation.
8
10 See DBIx::Class::Schema::Loader
11
13 This is the base class for the storage-specific
14 "DBIx::Class::Schema::*" classes, and implements the common
15 functionality between them.
16
18 These constructor options are the base options for "loader_options" in
19 DBIx::Class::Schema::Loader. Available constructor options are:
20
21 skip_relationships
22 Skip setting up relationships. The default is to attempt the loading
23 of relationships.
24
25 skip_load_external
26 Skip loading of other classes in @INC. The default is to merge all
27 other classes with the same name found in @INC into the schema file we
28 are creating.
29
30 naming
31 Static schemas (ones dumped to disk) will, by default, use the new-
32 style relationship names and singularized Results, unless you're
33 overwriting an existing dump made by an older version of
34 DBIx::Class::Schema::Loader, in which case the backward compatible
35 RelBuilder will be activated, and the appropriate monikerization used.
36
37 Specifying
38
39 naming => 'current'
40
41 will disable the backward-compatible RelBuilder and use the new-style
42 relationship names along with singularized Results, even when
43 overwriting a dump made with an earlier version.
44
45 The option also takes a hashref:
46
47 naming => { relationships => 'v7', monikers => 'v7' }
48
49 The keys are:
50
51 relationships
52 How to name relationship accessors.
53
54 monikers
55 How to name Result classes.
56
57 column_accessors
58 How to name column accessors in Result classes.
59
60 The values can be:
61
62 current
63 Latest style, whatever that happens to be.
64
65 v4 Unsingularlized monikers, "has_many" only relationships with no _id
66 stripping.
67
68 v5 Monikers singularized as whole words, "might_have" relationships
69 for FKs on "UNIQUE" constraints, "_id" stripping for belongs_to
70 relationships.
71
72 Some of the "_id" stripping edge cases in 0.05003 have been
73 reverted for the v5 RelBuilder.
74
75 v6 All monikers and relationships are inflected using
76 Lingua::EN::Inflect::Phrase, and there is more aggressive "_id"
77 stripping from relationship names.
78
79 In general, there is very little difference between v5 and v6
80 schemas.
81
82 v7 This mode is identical to "v6" mode, except that monikerization of
83 CamelCase table names is also done correctly.
84
85 CamelCase column names in case-preserving mode will also be handled
86 correctly for relationship name inflection. See "preserve_case".
87
88 In this mode, CamelCase "column_accessors" are normalized based on
89 case transition instead of just being lowercased, so "FooId"
90 becomes "foo_id".
91
92 If you don't have any CamelCase table or column names, you can
93 upgrade without breaking any of your code.
94
95 Dynamic schemas will always default to the 0.04XXX relationship names
96 and won't singularize Results for backward compatibility, to activate
97 the new RelBuilder and singularization put this in your "Schema.pm"
98 file:
99
100 __PACKAGE__->naming('current');
101
102 Or if you prefer to use 0.07XXX features but insure that nothing breaks
103 in the next major version upgrade:
104
105 __PACKAGE__->naming('v7');
106
107 generate_pod
108 By default POD will be generated for columns and relationships, using
109 database metadata for the text if available and supported.
110
111 Reading database metadata (e.g. "COMMENT ON TABLE some_table ...") is
112 only supported for Postgres right now.
113
114 Set this to 0 to turn off all POD generation.
115
116 pod_comment_mode
117 Controls where table comments appear in the generated POD. Smaller
118 table comments are appended to the "NAME" section of the documentation,
119 and larger ones are inserted into "DESCRIPTION" instead. You can force
120 a "DESCRIPTION" section to be generated with the comment always, only
121 use "NAME", or choose the length threshold at which the comment is
122 forced into the description.
123
124 name
125 Use "NAME" section only.
126
127 description
128 Force "DESCRIPTION" always.
129
130 auto
131 Use "DESCRIPTION" if length > "pod_comment_spillover_length", this
132 is the default.
133
134 pod_comment_spillover_length
135 When pod_comment_mode is set to "auto", this is the length of the
136 comment at which it will be forced into a separate description section.
137
138 The default is 60
139
140 relationship_attrs
141 Hashref of attributes to pass to each generated relationship, listed by
142 type. Also supports relationship type 'all', containing options to
143 pass to all generated relationships. Attributes set for more specific
144 relationship types override those set in 'all'.
145
146 For example:
147
148 relationship_attrs => {
149 belongs_to => { is_deferrable => 0 },
150 },
151
152 use this to turn off DEFERRABLE on your foreign key constraints.
153
154 debug
155 If set to true, each constructive DBIx::Class statement the loader
156 decides to execute will be "warn"-ed before execution.
157
158 db_schema
159 Set the name of the schema to load (schema in the sense that your
160 database vendor means it). Does not currently support loading more
161 than one schema name.
162
163 constraint
164 Only load tables matching regex. Best specified as a qr// regex.
165
166 exclude
167 Exclude tables matching regex. Best specified as a qr// regex.
168
169 moniker_map
170 Overrides the default table name to moniker translation. Can be either
171 a hashref of table keys and moniker values, or a coderef for a
172 translator function taking a single scalar table name argument and
173 returning a scalar moniker. If the hash entry does not exist, or the
174 function returns a false value, the code falls back to default behavior
175 for that table name.
176
177 The default behavior is to split on case transition and non-
178 alphanumeric boundaries, singularize the resulting phrase, then join
179 the titlecased words together. Examples:
180
181 Table Name | Moniker Name
182 ---------------------------------
183 luser | Luser
184 luser_group | LuserGroup
185 luser-opts | LuserOpt
186 stations_visited | StationVisited
187 routeChange | RouteChange
188
189 inflect_plural
190 Just like "moniker_map" above (can be hash/code-ref, falls back to
191 default if hash key does not exist or coderef returns false), but acts
192 as a map for pluralizing relationship names. The default behavior is
193 to utilize "to_PL" in Lingua::EN::Inflect::Number.
194
195 inflect_singular
196 As "inflect_plural" above, but for singularizing relationship names.
197 Default behavior is to utilize "to_S" in Lingua::EN::Inflect::Number.
198
199 schema_base_class
200 Base class for your schema classes. Defaults to 'DBIx::Class::Schema'.
201
202 result_base_class
203 Base class for your table classes (aka result classes). Defaults to
204 'DBIx::Class::Core'.
205
206 additional_base_classes
207 List of additional base classes all of your table classes will use.
208
209 left_base_classes
210 List of additional base classes all of your table classes will use that
211 need to be leftmost.
212
213 additional_classes
214 List of additional classes which all of your table classes will use.
215
216 components
217 List of additional components to be loaded into all of your table
218 classes. A good example would be InflateColumn::DateTime
219
220 resultset_components
221 List of additional ResultSet components to be loaded into your table
222 classes. A good example would be "AlwaysRS". Component
223 "ResultSetManager" will be automatically added to the above
224 "components" list if this option is set.
225
226 use_namespaces
227 This is now the default, to go back to "load_classes" in
228 DBIx::Class::Schema pass a 0.
229
230 Generate result class names suitable for "load_namespaces" in
231 DBIx::Class::Schema and call that instead of "load_classes" in
232 DBIx::Class::Schema. When using this option you can also specify any of
233 the options for "load_namespaces" (i.e. "result_namespace",
234 "resultset_namespace", "default_resultset_class"), and they will be
235 added to the call (and the generated result class names adjusted
236 appropriately).
237
238 dump_directory
239 This option is designed to be a tool to help you transition from this
240 loader to a manually-defined schema when you decide it's time to do so.
241
242 The value of this option is a perl libdir pathname. Within that
243 directory this module will create a baseline manual DBIx::Class::Schema
244 module set, based on what it creates at runtime in memory.
245
246 The created schema class will have the same classname as the one on
247 which you are setting this option (and the ResultSource classes will be
248 based on this name as well).
249
250 Normally you wouldn't hard-code this setting in your schema class, as
251 it is meant for one-time manual usage.
252
253 See "dump_to_dir" in DBIx::Class::Schema::Loader for examples of the
254 recommended way to access this functionality.
255
256 dump_overwrite
257 Deprecated. See "really_erase_my_files" below, which does *not* mean
258 the same thing as the old "dump_overwrite" setting from previous
259 releases.
260
261 really_erase_my_files
262 Default false. If true, Loader will unconditionally delete any
263 existing files before creating the new ones from scratch when dumping a
264 schema to disk.
265
266 The default behavior is instead to only replace the top portion of the
267 file, up to and including the final stanza which contains "# DO NOT
268 MODIFY THIS OR ANYTHING ABOVE!" leaving any customizations you placed
269 after that as they were.
270
271 When "really_erase_my_files" is not set, if the output file already
272 exists, but the aforementioned final stanza is not found, or the
273 checksum contained there does not match the generated contents, Loader
274 will croak and not touch the file.
275
276 You should really be using version control on your schema classes (and
277 all of the rest of your code for that matter). Don't blame me if a bug
278 in this code wipes something out when it shouldn't have, you've been
279 warned.
280
281 overwrite_modifications
282 Default false. If false, when updating existing files, Loader will
283 refuse to modify any Loader-generated code that has been modified since
284 its last run (as determined by the checksum Loader put in its comment
285 lines).
286
287 If true, Loader will discard any manual modifications that have been
288 made to Loader-generated code.
289
290 Again, you should be using version control on your schema classes. Be
291 careful with this option.
292
293 custom_column_info
294 Hook for adding extra attributes to the column_info for a column.
295
296 Must be a coderef that returns a hashref with the extra attributes.
297
298 Receives the table name, column name and column_info.
299
300 For example:
301
302 custom_column_info => sub {
303 my ($table_name, $column_name, $column_info) = @_;
304
305 if ($column_name eq 'dog' && $column_info->{default_value} eq 'snoopy') {
306 return { is_snoopy => 1 };
307 }
308 },
309
310 This attribute can also be used to set "inflate_datetime" on a non-
311 datetime column so it also receives the "datetime_timezone" and/or
312 "datetime_locale".
313
314 datetime_timezone
315 Sets the timezone attribute for DBIx::Class::InflateColumn::DateTime
316 for all columns with the DATE/DATETIME/TIMESTAMP data_types.
317
318 datetime_locale
319 Sets the locale attribute for DBIx::Class::InflateColumn::DateTime for
320 all columns with the DATE/DATETIME/TIMESTAMP data_types.
321
322 config_file
323 File in Perl format, which should return a HASH reference, from which
324 to read loader options.
325
326 preserve_case
327 Usually column names are lowercased, to make them easier to work with
328 in DBIx::Class. This option lets you turn this behavior off, if the
329 driver supports it.
330
331 Drivers for case sensitive databases like Sybase ASE or MSSQL with a
332 case-sensitive collation will turn this option on unconditionally.
333
334 Currently the drivers for SQLite, mysql, MSSQL and Firebird/InterBase
335 support setting this option.
336
337 qualify_objects
338 Set to true to prepend the "db_schema" to table names for
339 "__PACKAGE__->table" calls, and to some other things like Oracle
340 sequences.
341
342 use_moose
343 Creates Schema and Result classes that use Moose, MooseX::NonMoose and
344 namespace::autoclean. The default content after the md5 sum also makes
345 the classes immutable.
346
347 It is safe to upgrade your existing Schema to this option.
348
350 None of these methods are intended for direct invocation by regular
351 users of DBIx::Class::Schema::Loader. Some are proxied via
352 DBIx::Class::Schema::Loader.
353
354 new
355 Constructor for DBIx::Class::Schema::Loader::Base, used internally by
356 DBIx::Class::Schema::Loader.
357
358 load
359 Does the actual schema-construction work.
360
361 rescan
362 Arguments: schema
363
364 Rescan the database for changes. Returns a list of the newly added
365 table monikers.
366
367 The schema argument should be the schema class or object to be
368 affected. It should probably be derived from the original schema_class
369 used during "load".
370
371 tables
372 Returns a sorted list of loaded tables, using the original database
373 table names.
374
375 monikers
376 Returns a hashref of loaded table to moniker mappings. There will be
377 two entries for each table, the original name and the "normalized"
378 name, in the case that the two are different (such as databases that
379 like uppercase table names, or preserve your original mixed-case
380 definitions, or what-have-you).
381
382 classes
383 Returns a hashref of table to class mappings. In some cases it will
384 contain multiple entries per table for the original and normalized
385 table names, as above in "monikers".
386
388 DBIx::Class::Schema::Loader
389
391 See "AUTHOR" in DBIx::Class::Schema::Loader and "CONTRIBUTORS" in
392 DBIx::Class::Schema::Loader.
393
395 This library is free software; you can redistribute it and/or modify it
396 under the same terms as Perl itself.
397
398
399
400perl v5.12.2 2010-09-1D1BIx::Class::Schema::Loader::Base(3)