Skip to content

Commit

Permalink
Run migrations if there are pending migrations
Browse files Browse the repository at this point in the history
This drops relying on a settings entry in favor of lettings Rails
tell us when there are migrations that need to be applied.
  • Loading branch information
ehelms committed Dec 2, 2019
1 parent 36aa538 commit b11564c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
8 changes: 3 additions & 5 deletions manifests/database.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
contain $db_class

if $::foreman::db_manage_rake {
Class[$db_class] ~> Foreman_config_entry['db_pending_migration']
Class[$db_class] ~> Foreman::Rake['db:migrate']
}
}

Expand All @@ -21,11 +21,9 @@
'SEED_LOCATION' => $::foreman::initial_location,
}

foreman_config_entry { 'db_pending_migration':
value => false,
dry => true,
foreman::rake { 'db:migrate':
unless => "/usr/sbin/foreman-rake db:abort_if_pending_migrations"
}
~> foreman::rake { 'db:migrate': }
~> foreman_config_entry { 'db_pending_seed':
value => false,
dry => true,
Expand Down
2 changes: 2 additions & 0 deletions manifests/rake.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
$timeout = undef,
$user = $::foreman::user,
$app_root = $::foreman::app_root,
$unless = undef,
) {
# https://github.com/rodjek/puppet-lint/issues/327
# lint:ignore:arrow_alignment
Expand All @@ -14,6 +15,7 @@
logoutput => 'on_failure',
refreshonly => true,
timeout => $timeout,
unless => $unless,
}
# lint:endignore
}
2 changes: 0 additions & 2 deletions spec/classes/foreman_database_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

it { should_not contain_class('foreman::database::postgresql') }

it { should contain_foreman_config_entry('db_pending_migration') }
it { should contain_foreman__rake('db:migrate') }
it { should contain_foreman_config_entry('db_pending_seed') }
it { should contain_foreman__rake('db:seed') }
Expand All @@ -24,7 +23,6 @@
it { should compile.with_all_deps }
it { should contain_class('foreman::database::postgresql') }

it { should_not contain_foreman_config_entry('db_pending_migration') }
it { should_not contain_foreman__rake('db:migrate') }
it { should_not contain_foreman_config_entry('db_pending_seed') }
it { should_not contain_foreman__rake('db:seed') }
Expand Down
3 changes: 1 addition & 2 deletions spec/classes/foreman_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,9 @@
it { should_not contain_class('foreman::database::mysql') }
it {
should contain_class('foreman::database::postgresql')
.that_notifies('Foreman_config_entry[db_pending_migration]')
.that_notifies('Foreman::Rake[db:migrate]')
}

it { should contain_foreman_config_entry('db_pending_migration') }
it { should contain_foreman__rake('db:migrate') }
it { should contain_foreman_config_entry('db_pending_seed') }
it { should contain_foreman__rake('db:seed') }
Expand Down

0 comments on commit b11564c

Please sign in to comment.