Created
March 20, 2019 15:41
-
-
Save jcoyne/e56dd3226a1aa53b933fb10ad426c92e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
# Usage: | |
# ./bin/set-active-version <pathToVersionCSV> | |
puts 'Loading environment...' | |
require File.expand_path('../config/environment', __dir__) | |
require 'csv' | |
conn = ActiveRecord::Base.connection | |
versions = CSV.read(ARGV[0]).to_h | |
versions.each do |druid, version| | |
next unless version # Don't import if it doesn't have a version | |
conn.execute("UPDATE workflow_steps SET active_version = true WHERE druid = '#{druid}' AND version='#{version}'") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment