carp 'Install not possible as versions table already exists in database'
if $self->version_storage_is_installed;
- my $new_version = $self->to_version;
+ my $ddl = $self->_deploy;
- if ($new_version) {
- $self->_deploy;
-
- $self->version_storage->add_database_version({
- version => $new_version,
- # ddl => $ddl,
- # upgrade_sql => $upgrade_sql,
- });
- }
+ $self->version_storage->add_database_version({
+ version => $self->to_version,
+ ddl => $ddl,
+ });
}
sub upgrade {
my $guard = $self->schema->txn_scope_guard if $self->txn_wrap;
- foreach my $line (
- map @{$self->_read_sql_file($_)}, @{$self->_ddl_schema_consume_filenames(
+ my @sql = map @{$self->_read_sql_file($_)}, @{$self->_ddl_schema_consume_filenames(
$self->storage->sqlt_type,
$self->schema_version
- )}
- ) {
+ )};
+
+ foreach my $line (@sql) {
$storage->_query_start($line);
try {
# do a dbh_do cycle here, as we need some error checking in
}
$guard->commit if $self->txn_wrap;
+ return join "\n", @sql;
}
sub prepare_install {
ok( $vs->version_storage_is_installed, 'VersionStorage is now installed' );
-cmp_deeply(
- [ map +{
- version => $_->version,
- ddl => $_->ddl,
- upgrade_sql => $_->upgrade_sql,
- }, $vs->version_rs->search(undef, {order_by => 'id'})->all],
- [{
- version => '1.0',
- ddl => undef,
- upgrade_sql => undef
- }],
+ok(
+ eq_array(
+ [ $vs->version_rs->search(undef, {order_by => 'id'})->get_column('version')->all],
+ [ '1.0' ],
+ ),
'initial version works correctly'
);
});
is( $vs->database_version, '2.0', 'database version is 2.0');
-cmp_deeply(
- [ map +{
- version => $_->version,
- ddl => $_->ddl,
- upgrade_sql => $_->upgrade_sql,
- }, $vs->version_rs->search(undef, {order_by => 'id'})->all],
- [{
- version => '1.0',
- ddl => undef,
- upgrade_sql => undef
- },{
- version => '2.0',
- ddl => undef,
- upgrade_sql => undef
- }],
+ok(
+ eq_array(
+ [ $vs->version_rs->search(undef, {order_by => 'id'})->get_column('version')->all],
+ [ '1.0', '2.0', ],
+ ),
'adding another version works correctly'
);