Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix migrations being run from a plugin #22626

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions lib/manageiq/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ def self.manageiq_plugin_update(plugin_root = nil, force_bundle_update: true)
ensure_config_files

unless ENV["CI"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a separate topic, we have defined a separate ENV var for this step in the core bin/setup, but I don't think it's available in the plugin's bin/setup.

ENV["SKIP_DATABASE_SETUP"] = "true" if ENV["CI"]

I'm going to do this in a followup, but it might be preferable to default that same variable in the methods above, and that would allow the caller to do something like SKIP_DATABASE_SETUP=false in a CI env if they want to have the development database setup anyway (for example in a cypress test suite)

migrate_database
seed_database
# Update the local development database
create_database(plugin_root)
migrate_database(plugin_root)
seed_database(plugin_root)
end

setup_test_environment(:task_prefix => 'app:', :root => plugin_root) unless ENV["SKIP_TEST_RESET"]
Expand Down Expand Up @@ -96,19 +98,19 @@ def self.bundle_update(root = APP_ROOT, force: false)
puts "===== Begin Gemfile.lock =====\n\n#{lockfile_contents}\n\n===== End Gemfile.lock ====="
end

def self.create_database
puts "\n== Updating database =="
run_rake_task("db:create")
def self.create_database(root = APP_ROOT)
puts "\n== Creating database =="
run_rake_task("db:create", :root => root)
end

def self.migrate_database
def self.migrate_database(root = APP_ROOT)
puts "\n== Migrating database =="
run_rake_task("db:migrate")
run_rake_task("db:migrate", :root => root)
end

def self.seed_database
def self.seed_database(root = APP_ROOT)
puts "\n== Seeding database =="
run_rake_task("db:seed")
run_rake_task("db:seed", :root => root)
end

def self.setup_test_environment(task_prefix: '', root: APP_ROOT)
Expand Down