X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader%2FBase.pm;h=d3599360ff26f999503e754d2443694c8066bffa;hb=70b72fabc744cfcd0939fcba8c57e146df30eecf;hp=6664d706d907caea4fc8c7606827e3cc675c2184;hpb=a60b5b8dba39bf151b904b4fa5b53d65117b2801;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index 6664d70..d359936 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -14,7 +14,7 @@ use Cwd qw//; use Digest::MD5 qw//; require DBIx::Class; -our $VERSION = '0.03999_01'; +our $VERSION = '0.04001'; __PACKAGE__->mk_ro_accessors(qw/ schema @@ -34,6 +34,7 @@ __PACKAGE__->mk_ro_accessors(qw/ debug dump_directory dump_overwrite + really_erase_my_files db_schema _tables @@ -162,6 +163,11 @@ recommended way to access this functionality. =head2 dump_overwrite +Deprecated. See L below, which does *not* mean +the same thing as the old C setting from previous releases. + +=head2 really_erase_my_files + Default false. If true, Loader will unconditionally delete any existing files before creating the new ones from scratch when dumping a schema to disk. @@ -170,11 +176,15 @@ file, up to and including the final stanza which contains C<# DO NOT MODIFY THIS OR ANYTHING ABOVE!> leaving any customizations you placed after that as they were. -When C is not set, if the output file already exists, +When C is not set, if the output file already exists, but the aforementioned final stanza is not found, or the checksum contained there does not match the generated contents, Loader will croak and not touch the file. +You should really be using version control on your schema classes (and all +of the rest of your code for that matter). Don't blame me if a bug in this +code wipes something out when it shouldn't have, you've been warned. + =head1 METHODS None of these methods are intended for direct invocation by regular @@ -225,6 +235,10 @@ sub new { $self->{schema_class} ||= ( ref $self->{schema} || $self->{schema} ); $self->{schema} ||= $self->{schema_class}; + croak "dump_overwrite is deprecated. Please read the" + . " DBIx::Class::Schema::Loader::Base documentation" + if $self->{dump_overwrite}; + $self->{relbuilder} = DBIx::Class::Schema::Loader::RelBuilder->new( $self->schema_class, $self->inflect_plural, $self->inflect_singular ) if !$self->{skip_relationships}; @@ -292,7 +306,7 @@ sub _load_external { $self->_ext_stmt($class, $_); } $self->_ext_stmt($class, - q|# End of lines loaded from '$real_inc_path' | + qq|# End of lines loaded from '$real_inc_path' | ); close($fh) or croak "Failed to close $real_inc_path: $!"; @@ -449,9 +463,9 @@ sub _write_classfile { my $filename = $self->_get_dump_filename($class); $self->_ensure_dump_subdirs($class); - if (-f $filename && $self->dump_overwrite) { + if (-f $filename && $self->really_erase_my_files) { warn "Deleting existing file '$filename' due to " - . "'dump_overwrite' setting\n"; + . "'really_erase_my_files' setting\n"; unlink($filename); } @@ -511,7 +525,7 @@ sub _get_custom_content { } } - croak "Cannot not overwrite '$filename' without 'dump_overwrite'," + croak "Cannot not overwrite '$filename' without 'really_erase_my_files'," . " it does not appear to have been generated by Loader" if !$found; @@ -568,7 +582,7 @@ sub _make_src_class { $self->_use ($table_class, @{$self->additional_classes}); $self->_inject($table_class, @{$self->additional_base_classes}); - $self->_dbic_stmt($table_class, 'load_components', @{$self->components}, qw/PK::Auto Core/); + $self->_dbic_stmt($table_class, 'load_components', @{$self->components}, 'Core'); $self->_dbic_stmt($table_class, 'load_resultset_components', @{$self->resultset_components}) if @{$self->resultset_components};