Skip to content

Commit

Permalink
still fighting this one
Browse files Browse the repository at this point in the history
  • Loading branch information
amcates committed Jun 14, 2018
1 parent 93e57f9 commit f8efc7c
Showing 1 changed file with 0 additions and 36 deletions.
36 changes: 0 additions & 36 deletions db/migrate/20171106161235_change_ids_from_int_to_bigint.rb
Original file line number Diff line number Diff line change
@@ -1,41 +1,5 @@
class ChangeIdsFromIntToBigint < ActiveRecord::Migration[5.1]
def change
#### This needs to be defined because of the order of migrations ####
class PermissibleValue < ApplicationRecord

# Get the first PermissibleValue value using a category and key
def self.get_value(category, key)
PermissibleValue.where(category: category, key: key).first.try(:value)
end

# Get an array of PermissibleValue keys with the given category
def self.get_key_list(category, default=nil)
unless default.nil?
PermissibleValue.where(category: category, default: default).pluck(:key)
else
PermissibleValue.where(category: category).pluck(:key)
end
end

# Get a hash of PermissibleValue keys as they keys and values as values
def self.get_hash(category, default=nil)
unless default.nil?
Hash[PermissibleValue.where(category: category, default: default).pluck(:key, :value)]
else
Hash[PermissibleValue.where(category: category).pluck(:key, :value)]
end
end

# Get a hash of PermissibleValue values as the keys and keys as values
def self.get_inverted_hash(category, default=nil)
unless default.nil?
Hash[PermissibleValue.where(category: category, default: default).pluck(:value, :key)]
else
Hash[PermissibleValue.where(category: category).pluck(:value, :key)]
end
end
end
#### end model override ####

db_models, db_habtms = map_models_to_tablenames
non_ar_tables = (ActiveRecord::Base.connection.tables - db_models.keys - db_habtms)
Expand Down

0 comments on commit f8efc7c

Please sign in to comment.