db_schema
_tables
classes
+ _upgrading_classes
monikers
dynamic
naming
- _upgrading_from
/);
__PACKAGE__->mk_accessors(qw/
version_to_dump
schema_version_to_dump
+ _upgrading_from
/);
=head1 NAME
$self->{monikers} = {};
$self->{classes} = {};
+ $self->{_upgrading_classes} = {};
$self->{schema_class} ||= ( ref $self->{schema} || $self->{schema} );
$self->{schema} ||= $self->{schema_class};
details.
EOF
}
+ else {
+ $self->_upgrading_from('v4');
+ }
$self->naming->{relationships} ||= 'v4';
$self->naming->{monikers} ||= 'v4';
details.
EOF
}
+ else {
+ $self->_upgrading_from($v);
+ }
$self->naming->{relationships} ||= $v;
$self->naming->{monikers} ||= $v;
my $class_path = $self->_class_path($class);
delete $INC{ $class_path };
+
+# kill redefined warnings
+ local $SIG{__WARN__} = sub {
+ warn @_ unless $_[0] =~ /^Subroutine \S+ redefined/;
+ };
+
eval "require $class;";
}
my ($custom_content, $old_md5, $old_ver, $old_ts) = $self->_get_custom_content($class, $filename);
+ if ($self->_upgrading_from) {
+ my $old_class = $self->_upgrading_classes->{$class};
+
+ if ($old_class && ($old_class ne $class)) {
+ my $old_filename = $self->_get_dump_filename($old_class);
+
+ my ($old_custom_content) = $self->_get_custom_content(
+ $old_class, $old_filename
+ );
+
+ $custom_content .= "\n" . $old_custom_content
+ if $old_custom_content;
+
+ unlink $old_filename;
+ }
+ }
+
$text .= qq|$_\n|
for @{$self->{_dump_storage}->{$class} || []};
}
my $table_class = join(q{::}, @result_namespace, $table_moniker);
+ if (my $upgrading_v = $self->_upgrading_from) {
+ local $self->naming->{monikers} = $upgrading_v;
+
+ my $old_class = join(q{::}, @result_namespace,
+ $self->_table2moniker($table));
+
+ $self->_upgrading_classes->{$table_class} = $old_class;
+ }
+
my $table_normalized = lc $table;
$self->classes->{$table} = $table_class;
$self->classes->{$table_normalized} = $table_class;
sub run_loader {
my %loader_opts = @_;
- Class::Unload->unload($SCHEMA_CLASS);
+ eval {
+ foreach my $source_name ($SCHEMA_CLASS->clone->sources) {
+ Class::Unload->unload("${SCHEMA_CLASS}::${source_name}");
+ }
+
+ Class::Unload->unload($SCHEMA_CLASS);
+ };
+ undef $@;
my @connect_info = $make_dbictest_db2::dsn;
my @loader_warnings;
my $res = run_loader(naming => 'v4');
is_deeply $res->{warnings}, [], 'no warnings with naming attribute set';
+
+ run_v4_tests($res);
}
# test upgraded dynamic schema
run_v5_tests($res);
}
-
# test running against v4 schema without upgrade
{
# write out the 0.04006 Schema.pm we have in __DATA__
'correct warnings on upgrading static schema (with "naming" set)';
is scalar @{ $res->{warnings} }, 2,
-'correct number of warnings on upgrading static schema (with "naming" set)';
+'correct number of warnings on upgrading static schema (with "naming" set)'
+ or diag @{ $res->{warnings} };
run_v5_tests($res);