Sha256: a0ac4bee1e64f2ca7b4928a867062cd498244ef2f8d838e9ff69a2041bb4cf64
Contents?: true
Size: 1.55 KB
Versions: 8
Compression:
Stored size: 1.55 KB
Contents
# Copyright:: (c) Autotelik Media Ltd 2012 # Author :: Tom Statter # Date :: March 2012 # License:: MIT. Free, Open Source. # # Usage:: # bundle exec thor help datashift:spreeboot # bundle exec thor datashift:spreeboot:cleanup # # Note, not DataShift, case sensitive, create namespace for command line : datashift module Datashift class Spreeboot < Thor include DataShift::Logging desc "cleanup", "Remove Spree Product/Variant data from DB" def cleanup() require File.expand_path('config/environment.rb') require 'spree_helper' require File.expand_path('config/environment.rb') ActiveRecord::Base.connection.execute("TRUNCATE spree_products_taxons") cleanup = %w{ Image OptionType OptionValue Product Property ProductGroup ProductProperty ProductOptionType Variant Taxonomy Taxon } cleanup.each do |k| klass = DataShift::SpreeHelper::get_spree_class(k) if(klass) puts "Clearing model #{klass}" begin klass.delete_all rescue => e puts e end else puts "WARNING - Could not find AR model for class name #{k}" end end image_bank = 'public/spree/products' if(File.exists?(image_bank) ) puts "Removing old Product assets from '#{image_bank}'" FileUtils::rm_rf(image_bank) end FileUtils::rm_rf('MissingRecords') if(File.exists?('MissingRecords') ) end end end
Version data entries
8 entries across 8 versions & 2 rubygems