Sha256: d1ebf8a03b97b76eb7eb9ea426218e82b801938f204f2bcf0445ad0c53712516

Contents?: true

Size: 376 Bytes

Versions: 9

Compression:

Stored size: 376 Bytes

Contents

class EnsureDefaultStore < ActiveRecord::Migration
  class Store < ActiveRecord::Base
    self.table_name = 'spree_stores'
  end

  def up
    unless Store.where(default: true).exists?
      store = Store.first
      raise "Database has no stores. One should have been created in a previous migration." unless store
      store.update_column(:default, true)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
solidus_core-1.4.2 db/migrate/20160608162651_ensure_default_store.rb
solidus_core-1.3.2 db/migrate/20160608162651_ensure_default_store.rb
solidus_core-1.4.1 db/migrate/20160608162651_ensure_default_store.rb
solidus_core-1.4.0 db/migrate/20160608162651_ensure_default_store.rb
solidus_core-1.4.0.rc1 db/migrate/20160608162651_ensure_default_store.rb
solidus_core-1.4.0.beta1 db/migrate/20160608162651_ensure_default_store.rb
solidus_core-1.3.1 db/migrate/20160608162651_ensure_default_store.rb
solidus_core-1.3.0 db/migrate/20160608162651_ensure_default_store.rb
solidus_core-1.3.0.rc2 db/migrate/20160608162651_ensure_default_store.rb