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
def import_supplier_products(path) | |
fail unless File.file? path | |
supplier_mappings = { | |
'224' => '372bd2a4-258d-48f3-9f84-598e1f09b657', | |
'445' => '0235c6b5-b399-40ad-91f3-cbe7b02ca565' | |
} | |
imported, failed = [], [] | |
CSV.foreach(path) do |row| | |
manufacturer = Registry::Manufacturer.find_or_create_by(name: row[3]) | |
sp = SupplierProduct.new( |
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
files = Dir.glob("db/migrate/*") | |
timestamps = files.collect{|f| f.split("/").last.split("_").first} | |
timestamps.count | |
migrations = ActiveRecord::Base.connection.execute("SELECT version FROM schema_migrations", as: :array).to_a.flatten | |
needs = timestamps - migrations | |
files_needs = files.select { |f| needs.include? f.split("/").last.split("_").first } | |
files_needs.sort.each do |f| | |
begin | |
require "#{Rails.root}/#{f}" | |
f.split('/').last.split('_')[1..-1].join('_').split('.').first.camelize.constantize.new.up |
NewerOlder