debian-mirror-gitlab/scripts/db_tasks
2023-04-23 21:23:45 +05:30

17 lines
447 B
Ruby
Executable file

#!/usr/bin/env ruby
# frozen_string_literal: true
require 'yaml'
rails_env = ENV.fetch('RAILS_ENV')
database_config = YAML.load_file(File.join(File.expand_path('..', __dir__), 'config', 'database.yml'))[rails_env]
task = ARGV.shift
raise ArgumentError, 'You need to pass a task name!' unless task
task = "#{task}:main" unless database_config.one?
cmd = ['bundle', 'exec', 'rake', task, *ARGV]
puts "Running: `#{cmd.join(' ')}`"
system(*cmd)