Revision history for Perl extension DBIx::Class::Schema::Loader
+ - Add options to omit the version and timestamp from the
+ generated code (RT#92300)
+
0.07039 2014-01-06
- Fix table listing with DBD::DB2 >= 1.85 (RT#91764)
- Add accessor for the list of (re)generated classes
overwrite_modifications
dry_run
generated_classes
+ omit_version
+ omit_timestamp
relationship_attrs
Again, you should be using version control on your schema classes. Be
careful with this option.
+=head2 omit_version
+
+Omit the package version from the signature comment.
+
+=head2 omit_timestamp
+
+Omit the creation timestamp from the signature comment.
+
=head2 custom_column_info
Hook for adding extra attributes to the
sub _sig_comment {
my ($self, $version, $ts) = @_;
return qq|\n\n# Created by DBIx::Class::Schema::Loader|
- . qq| v| . $version
- . q| @ | . $ts
+ . (defined($version) ? q| v| . $version : '')
+ . (defined($ts) ? q| @ | . $ts : '')
. qq|\n# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:|;
}
return if $self->dry_run;
$text .= $self->_sig_comment(
- $self->version_to_dump,
- POSIX::strftime('%Y-%m-%d %H:%M:%S', localtime)
+ $self->omit_version ? undef : $self->version_to_dump,
+ $self->omit_timestamp ? undef : POSIX::strftime('%Y-%m-%d %H:%M:%S', localtime)
);
open(my $fh, '>:encoding(UTF-8)', $filename)
$md5 = $2;
# Pull out the version and timestamp from the line above
- ($ver, $ts) = $gen =~ m/^# Created by DBIx::Class::Schema::Loader v(.*?) @ (.*?)\r?\Z/m;
+ ($ver, $ts) = $gen =~ m/^# Created by DBIx::Class::Schema::Loader( v[\d.]+)?( @ [\d-]+ [\d:]+)?\r?\Z/m;
+ $ver =~ s/^ v// if $ver;
+ $ts =~ s/^ @ // if $ts;
$gen .= $pre_md5;
croak "Checksum mismatch in '$fn', the auto-generated part of the file has been modified outside of this loader. Aborting.\nIf you want to overwrite these modifications, set the 'overwrite_modifications' loader option.\n"
(my $schema_dir = $schema_file) =~ s/\.pm\z//;
ok( !-e $schema_dir, "dry-run doesn't create subdirectory for schema namespace" );
+# test omit_version (RT#92300)
+$t->dump_test(
+ classname => 'DBICTest::DumpMore::omit_version',
+ options => {
+ omit_version => 1,
+ },
+ regexes => {
+ Foo => [
+ qr/^\# Created by DBIx::Class::Schema::Loader @ \d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d$/m,
+ ],
+ },
+);
+
+# test omit_timestamp (RT#92300)
+$t->dump_test(
+ classname => 'DBICTest::DumpMore::omit_timestamp',
+ options => {
+ omit_timestamp => 1,
+ },
+ regexes => {
+ Foo => [
+ qr/^\# Created by DBIx::Class::Schema::Loader v[\d.]+$/m,
+ ],
+ },
+);
+
+# test omit_version and omit_timestamp simultaneously (RT#92300)
+$t->dump_test(
+ classname => 'DBICTest::DumpMore::omit_both',
+ options => {
+ omit_version => 1,
+ omit_timestamp => 1,
+ },
+ # A positive regex here would match the top comment
+ neg_regexes => {
+ Foo => [
+ qr/^\# Created by DBIx::Class::Schema::Loader.+$/m,
+ ],
+ },
+);
+
done_testing;
# vim:et sts=4 sw=4 tw=0: