debian-mirror-gitlab/scripts/db_tasks

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
526 B
Text
Raw Normal View History

2023-04-23 21:23:45 +05:30
#!/usr/bin/env ruby
# frozen_string_literal: true
2022-01-26 12:08:38 +05:30
2023-04-23 21:23:45 +05:30
require 'yaml'
2022-01-26 12:08:38 +05:30
2023-04-23 21:23:45 +05:30
rails_env = ENV.fetch('RAILS_ENV')
database_config = YAML.load_file(File.join(File.expand_path('..', __dir__), 'config', 'database.yml'))[rails_env]
2023-05-27 22:25:52 +05:30
database_config.reject! { |_k, v| v["database_tasks"] == false }
2022-01-26 12:08:38 +05:30
2023-04-23 21:23:45 +05:30
task = ARGV.shift
raise ArgumentError, 'You need to pass a task name!' unless task
2022-01-26 12:08:38 +05:30
2023-04-23 21:23:45 +05:30
task = "#{task}:main" unless database_config.one?
cmd = ['bundle', 'exec', 'rake', task, *ARGV]
puts "Running: `#{cmd.join(' ')}`"
2023-05-27 22:25:52 +05:30
exit 1 unless system(*cmd)