Merge pull request #5241 from Matt-Yorkley/remove-old-migrations

Remove old migrations!
This commit is contained in:
Pau Pérez Fabregat
2020-04-22 17:01:01 +02:00
committed by GitHub
417 changed files with 13 additions and 7125 deletions

View File

@@ -1,389 +0,0 @@
class SpreeZeroNineZero < ActiveRecord::Migration
# This is a legacy migration consolidating all of the database changes needed as of Spree 0.9.0
# (See http://railsdog.lighthouseapp.com/projects/31096-spree/tickets/772)
def change
create_table :addresses, :force => true do |t|
t.string :firstname, :lastname, :address1, :address2, :city,
:zipcode, :phone, :state_name, :alternative_phone
t.references :state
t.references :country
t.timestamps
end
create_table :adjustments, :force => true do |t|
t.integer :position, :adjustment_source_id
t.decimal :amount, :precision => 8, :scale => 2, :default => 0.0, :null => false
t.string :type, :description, :adjustment_source_type, :secondary_type
t.references :order
t.timestamps
end
create_table :assets, :force => true do |t|
t.integer :viewable_id, :attachment_width, :attachment_height,
:attachment_size, :position
t.string :viewable_type, :limit => 50
t.string :attachment_content_type, :attachment_file_name
t.string :type, :limit => 75
t.datetime :attachment_updated_at
end
create_table :calculators, :force => true do |t|
t.string :type
t.integer :calculable_id, :null => false
t.string :calculable_type, :null => false
t.timestamps
end
create_table :checkouts, :force => true do |t|
t.references :order
t.string :email, :ip_address
t.text :special_instructions
t.integer :bill_address_id
t.datetime :completed_at
t.timestamps
end
create_table :configurations, :force => true do |t|
t.string :name
t.string :type, :limit => 50
t.timestamps
end
add_index :configurations, [:name, :type], :name => 'index_configurations_on_name_and_type'
create_table :countries, :force => true do |t|
t.string :iso_name, :iso, :iso3, :name
t.integer :numcode
end
create_table :coupons, :force => true do |t|
t.string :code, :description
t.integer :usage_limit
t.boolean :combine
t.datetime :expires_at, :starts_at
t.timestamps
end
create_table :creditcard_txns, :force => true do |t|
t.integer :creditcard_payment_id, :txn_type
t.decimal :amount, :precision => 8, :scale => 2, :default => 0.0, :null => false
t.string :response_code
t.text :avs_response, :cvv_response
t.timestamps
end
create_table :creditcards, :force => true do |t|
t.text :number, :verification_value
t.string :month, :year, :cc_type, :display_number, :first_name,
:last_name, :start_month, :start_year, :issue_number
t.references :address
t.references :checkout
t.timestamps
end
create_table :gateway_configurations, :force => true do |t|
t.references :gateway
t.timestamps
end
create_table :gateway_option_values, :force => true do |t|
t.references :gateway_configuration
t.references :gateway_option
t.text :value
t.timestamps
end
create_table :gateway_options, :force => true do |t|
t.string :name
t.text :description
t.boolean :textarea, :default => false
t.references :gateway
t.timestamps
end
create_table :gateways, :force => true do |t|
t.string :clazz, :name
t.text :description
t.boolean :active
t.timestamps
end
create_table :inventory_units, :force => true do |t|
t.integer :lock_version, :default => 0
t.string :state
t.references :variant
t.references :order
t.timestamps
end
create_table :line_items, :force => true do |t|
t.references :order
t.references :variant
t.integer :quantity, :null => false
t.decimal :price, :precision => 8, :scale => 2, :null => false
t.timestamps
end
add_index :line_items, :order_id, :name => 'index_line_items_on_order_id'
add_index :line_items, :variant_id, :name => 'index_line_items_on_variant_id'
create_table :option_types, :force => true do |t|
t.string :name, :limit => 100
t.string :presentation, :limit => 100
t.timestamps
end
create_table :option_types_prototypes, :id => false, :force => true do |t|
t.references :prototype
t.references :option_type
end
create_table :option_values, :force => true do |t|
t.integer :position
t.string :name, :presentation
t.references :option_type
t.timestamps
end
create_table :option_values_variants, :id => false, :force => true do |t|
t.integer :variant_id
t.integer :option_value_id
end
add_index :option_values_variants, :variant_id, :name => 'index_option_values_variants_on_variant_id'
create_table :orders, :force => true do |t|
t.string :number, :limit => 15
t.decimal :item_total, :precision => 8, :scale => 2, :default => 0.0, :null => false
t.decimal :total, :precision => 8, :scale => 2, :default => 0.0, :null => false
t.string :state
t.string :token
t.decimal :adjustment_total, :precision => 8, :scale => 2, :default => 0.0, :null => false
t.decimal :credit_total, :precision => 8, :scale => 2, :default => 0.0, :null => false
t.references :user
t.timestamps
end
add_index :orders, :number, :name => 'index_orders_on_number'
create_table :payments, :force => true do |t|
t.decimal :amount, :precision => 8, :scale => 2, :default => 0.0, :null => false
t.string :type
t.references :order
t.references :creditcard
t.timestamps
end
create_table :preferences, :force => true do |t|
t.string :attribute, :null => false, :limit => 100
t.integer :owner_id, :null => false, :limit => 30
t.string :owner_type, :null => false, :limit => 50
t.integer :group_id
t.string :group_type, :limit => 50
t.string :value
t.timestamps
end
add_index :preferences, [:owner_id, :owner_type, :attribute, :group_id, :group_type], :name => 'index_preferences_on_owner_and_attribute_and_preference', :unique => true
create_table :product_option_types, :force => true do |t|
t.integer :position
t.references :product
t.references :option_type
t.timestamps
end
create_table :product_properties, :force => true do |t|
t.string :value
t.references :product
t.references :property
t.timestamps
end
create_table :products, :force => true do |t|
t.string :name, :default => '', :null => false
t.text :description
t.datetime :available_on, :deleted_at
t.string :permalink, :meta_description, :meta_keywords
t.references :tax_category
t.references :shipping_category
t.timestamps
end
add_index :products, :available_on, :name => 'index_products_on_available_on'
add_index :products, :deleted_at, :name => 'index_products_on_deleted_at'
add_index :products, :name, :name => 'index_products_on_name'
add_index :products, :permalink, :name => 'index_products_on_permalink'
create_table :products_taxons, :id => false, :force => true do |t|
t.references :product
t.references :taxon
end
add_index :products_taxons, :product_id, :name => 'index_products_taxons_on_product_id'
add_index :products_taxons, :taxon_id, :name => 'index_products_taxons_on_taxon_id'
create_table :properties, :force => true do |t|
t.string :name
t.string :presentation, :null => false
t.timestamps
end
create_table :properties_prototypes, :id => false, :force => true do |t|
t.references :prototype
t.references :property
end
create_table :prototypes, :force => true do |t|
t.string :name
t.timestamps
end
create_table :roles, :force => true do |t|
t.string :name
end
create_table :roles_users, :id => false, :force => true do |t|
t.references :role
t.references :user
end
add_index :roles_users, :role_id, :name => 'index_roles_users_on_role_id'
add_index :roles_users, :user_id, :name => 'index_roles_users_on_user_id'
create_table :shipments, :force => true do |t|
t.string :tracking, :number
t.decimal :cost, :precision => 8, :scale => 2
t.datetime :shipped_at
t.references :order
t.references :shipping_method
t.references :address
t.timestamps
end
create_table :shipping_categories, :force => true do |t|
t.string :name
t.timestamps
end
create_table :shipping_methods, :force => true do |t|
t.string :name
t.references :zone
t.timestamps
end
create_table :state_events, :force => true do |t|
t.string :name, :previous_state
t.references :order
t.references :user
t.timestamps
end
create_table :states, :force => true do |t|
t.string :name
t.string :abbr
t.references :country
end
create_table :tax_categories, :force => true do |t|
t.string :name, :description
t.timestamps
end
create_table :tax_rates, :force => true do |t|
t.decimal :amount, :precision => 8, :scale => 4
t.references :zone
t.references :tax_category
t.timestamps
end
create_table :taxonomies, :force => true do |t|
t.string :name, :null => false
t.timestamps
end
create_table :taxons, :force => true do |t|
t.integer :parent_id
t.integer :position, :default => 0
t.string :name, :null => false
t.string :permalink
t.references :taxonomy
t.timestamps
end
create_table :users, :force => true do |t|
t.string :crypted_password, :limit => 128, :default => '', :null => false
t.string :salt, :limit => 128, :default => '', :null => false
t.string :email, :remember_token, :remember_token_expires_at,
:persistence_token, :single_access_token, :perishable_token
t.integer :login_count, :default => 0, :null => false
t.integer :failed_login_count, :default => 0, :null => false
t.datetime :last_request_at, :current_login_at, :last_login_at
t.string :current_login_ip, :last_login_ip, :login
t.integer :ship_address_id, :bill_address_id
t.timestamps
end
create_table :variants, :force => true do |t|
t.string :sku, :default => '', :null => false
t.decimal :price, :precision => 8, :scale => 2, :null => false
t.decimal :weight, :precision => 8, :scale => 2
t.decimal :height, :precision => 8, :scale => 2
t.decimal :width, :precision => 8, :scale => 2
t.decimal :depth, :precision => 8, :scale => 2
t.datetime :deleted_at
t.boolean :is_master, :default => false
t.references :product
end
add_index :variants, :product_id, :name => 'index_variants_on_product_id'
create_table :zone_members, :force => true do |t|
t.integer :zoneable_id
t.string :zoneable_type
t.references :zone
t.timestamps
end
create_table :zones, :force => true do |t|
t.string :name, :description
t.timestamps
end
end
end

View File

@@ -1,6 +0,0 @@
class CreateIndexesForInventoryUnits < ActiveRecord::Migration
def change
add_index :inventory_units, :variant_id
add_index :inventory_units, :order_id
end
end

View File

@@ -1,49 +0,0 @@
class AddCountOnHandToVariantsAndProducts < ActiveRecord::Migration
def up
add_column :variants, :count_on_hand, :integer, :default => 0, :null => false
add_column :products, :count_on_hand, :integer, :default => 0, :null => false
# Due to our namespacing changes, this migration (from earlier Spree versions) is broken
# To fix it, temporarily set table name on each of the models involved
# And then...
Spree::Variant.table_name = 'variants'
Spree::Product.table_name = 'products'
Spree::InventoryUnit.table_name = 'inventory_units'
# In some cases needed to reflect changes in table structure
Spree::Variant.reset_column_information
Spree::Product.reset_column_information
say_with_time 'Transfering inventory units with status on_hand to variants table...' do
Spree::Variant.all.each do |v|
v.update_attribute(:count_on_hand, v.inventory_units.with_state('on_hand').size)
Spree::InventoryUnit.destroy_all(:variant_id => v.id, :state => 'on_hand')
end
end
say_with_time 'Updating products count on hand' do
Spree::Product.all.each do |p|
product_count_on_hand = p.has_variants? ?
p.variants.inject(0) { |acc, v| acc + v.count_on_hand } :
(p.master ? p.master.count_on_hand : 0)
p.update_attribute(:count_on_hand, product_count_on_hand)
end
end
# ... Switch things back at the end of the migration
Spree::Variant.table_name = 'spree_variants'
Spree::Product.table_name = 'spree_products'
Spree::InventoryUnit.table_name = 'spree_inventory_units'
end
def down
Spree::Variant.all.each do |v|
v.count_on_hand.times do
Spree::InventoryUnit.create(:variant => variant, :state => 'on_hand')
end
end
remove_column :variants, :count_on_hand
remove_column :products, :count_on_hand
end
end

View File

@@ -1,46 +0,0 @@
class ChangeTaxonsToNestedSet < ActiveRecord::Migration
def up
add_column :taxons, :lft, :integer
add_column :taxons, :rgt, :integer
Spree::Taxon.reset_column_information # So the new root ids get saved
# Temporarily set the table back to taxons
Spree::Taxon.table_name = 'taxons'
Spree::Taxon.class_eval do
# adapted from awesome nested set to use 'position' information
indices = {}
left_column_name = 'lft'
right_column_name = 'rgt'
quoted_parent_column_name = 'parent_id'
scope = lambda{|node|}
set_left_and_rights = lambda do |node|
# set left
node[left_column_name] = indices[scope.call(node)] += 1
# find
where("#{quoted_parent_column_name} = ?", node).order('position ASC').each{ |n| set_left_and_rights.call(n) }
# set right
node[right_column_name] = indices[scope.call(node)] += 1
node.save!
end
# Find root node(s)
where("#{quoted_parent_column_name}" => nil).order('position ASC').each do |root_node|
# setup index for this scope
indices[scope.call(root_node)] ||= 0
set_left_and_rights.call(root_node)
end
end
# Set it back after the migration
Spree::Taxon.table_name = 'spree_taxons'
end
def down
remove_column :taxons, :lft
remove_column :taxons, :rgt
end
end

View File

@@ -1,54 +0,0 @@
class MoveToConfigurableGateways < ActiveRecord::Migration
def up
drop_table :gateways
drop_table :gateway_options
drop_table :gateway_option_values
drop_table :gateway_configurations
create_table :gateways, :force => true do |t|
t.string :type, :name
t.text :description
t.boolean :active, :default => true
t.string :environment, :default => 'development'
t.string :server, :default => 'test'
t.boolean :test_mode, :default => true
t.timestamps
end
end
def down
drop_table :gateways
create_table :gateway_configurations, :force => true do |t|
t.references :gateway
t.timestamps
end
create_table :gateway_option_values, :force => true do |t|
t.text :value
t.references :gateway_configuration
t.references :gateway_option
t.timestamps
end
create_table :gateway_options, :force => true do |t|
t.string :name
t.text :description
t.boolean :textarea, :default => false
t.references :gateway
t.timestamps
end
create_table :gateways, :force => true do |t|
t.string :clazz, :name
t.text :description
t.boolean :active
t.timestamps
end
end
end

View File

@@ -1,18 +0,0 @@
class ProductGroupsAndScopes < ActiveRecord::Migration
def change
create_table :product_groups do |t|
t.string :name, :permalink, :order
end
create_table :product_scopes do |t|
t.string :name
t.text :arguments
t.references :product_group
end
add_index :product_groups, :name
add_index :product_groups, :permalink
add_index :product_scopes, :name
add_index :product_scopes, :product_group_id
end
end

View File

@@ -1,15 +0,0 @@
class AddOpenIdAuthenticationTables < ActiveRecord::Migration
def change
create_table :open_id_authentication_associations, :force => true do |t|
t.integer :issued, :lifetime
t.string :handle, :assoc_type
t.binary :server_url, :secret
end
create_table :open_id_authentication_nonces, :force => true do |t|
t.integer :timestamp, :null => false
t.string :server_url, :null => true
t.string :salt, :null => false
end
end
end

View File

@@ -1,24 +0,0 @@
class AddOpenidFieldToUsers < ActiveRecord::Migration
def up
add_column :users, :openid_identifier, :string
add_index :users, :openid_identifier
change_column :users, :login, :string, :default => nil, :null => true
change_column :users, :crypted_password, :string, :default => nil, :null => true
change_column :users, :salt, :string, :default => nil, :null => true
end
def down
remove_column :users, :openid_identifier
# Due to namespacing change, temporarily set the table back to users
Spree::User.table_name = 'users'
[:login, :crypted_password, :salt].each do |field|
Spree::User.where(field => nil).each { |user| user.update_attribute(field, '') if user.send(field).nil? }
change_column :users, field, :string, :default => '', :null => false
end
Spree::User.table_name = 'spree_users'
end
end

View File

@@ -1,10 +0,0 @@
class ChangePreferenceValueType < ActiveRecord::Migration
def up
remove_index :preferences, :name => 'index_preferences_on_owner_and_attribute_and_preference'
change_column :preferences, :value, :text
end
def down
change_column :preferences, :value, :string
end
end

View File

@@ -1,12 +0,0 @@
class CreateBillingIntegrations < ActiveRecord::Migration
def change
create_table :billing_integrations do |t|
t.string :type, :name
t.text :description
t.boolean :active, :default => true
t.string :environment, :default => 'development'
t.timestamps
end
end
end

View File

@@ -1,39 +0,0 @@
class Checkout < ActiveRecord::Base; end;
# Hack to prevent issues with legacy migrations
class Order < ActiveRecord::Base
has_one :checkout
end
class ChargeRefactoring < ActiveRecord::Migration
def up
# Temporarily set table name for legacy support
Spree::Adjustment.table_name = 'adjustments'
add_column :orders, :completed_at, :timestamp
Order.reset_column_information
Order.all.each { |o| o.update_attribute(:completed_at, o.checkout && o.checkout.read_attribute(:completed_at)) }
remove_column :checkouts, :completed_at
change_column :adjustments, :amount, :decimal, :null => true, :default => nil, :precision => 8, :scale => 2
Spree::Adjustment.update_all :type => 'secondary_type'
Spree::Adjustment.where(:type => 'Credit').update_all(:type => 'CouponCredit')
remove_column :adjustments, :secondary_type
# Reset table name
Spree::Adjustment.table_name = 'spree_adjustments'
end
def down
add_column :checkouts, :completed_at, :timestamp
Spree::Checkout.reset_column_information
Spree::Checkout.all.each { |c| c.update_attribute(:completed_at, c.order && c.order.completed_at) }
remove_column :orders, :completed_at
add_column :adjustments, :secondary_type, :string
Spree::Adjustment.update_all :secondary_type => 'type'
Spree::Adjustment.where('type LIKE ?', '%Charge').update_all(:type => 'Charge')
Spree::Adjustment.where('type LIKE ?', '%Credit').update_all(:type => 'Credit')
change_column :adjustments, :amount, :decimal, :null => false, :default => 0, :precision => 8, :scale => 2
end
end

View File

@@ -1,11 +0,0 @@
class AddSomeIndexes < ActiveRecord::Migration
def change
add_index :taxons, :permalink
add_index :taxons, :parent_id
add_index :taxons, :taxonomy_id
add_index :assets, :viewable_id
add_index :assets, [:viewable_type, :type]
add_index :product_properties, :product_id
add_index :option_values_variants, [:variant_id, :option_value_id]
end
end

View File

@@ -1,5 +0,0 @@
class CheckoutStateMachine < ActiveRecord::Migration
def change
add_column :checkouts, :state, :string
end
end

View File

@@ -1,5 +0,0 @@
class StateForShipments < ActiveRecord::Migration
def change
add_column :shipments, :state, :string
end
end

View File

@@ -1,12 +0,0 @@
class MakeStateEventsPolymorphic < ActiveRecord::Migration
def up
rename_column :state_events, :order_id, :stateful_id
add_column :state_events, :stateful_type, :string
execute "UPDATE state_events SET stateful_type = 'Order'"
end
def down
rename_column :state_events, :stateful_id, :order_id
remove_column :state_events, :stateful_type
end
end

View File

@@ -1,5 +0,0 @@
class ShipAddressIdForCheckouts < ActiveRecord::Migration
def change
add_column :checkouts, :ship_address_id, :integer
end
end

View File

@@ -1,5 +0,0 @@
class ShippingMethodIdForCheckouts < ActiveRecord::Migration
def change
add_column :checkouts, :shipping_method_id, :integer
end
end

View File

@@ -1,14 +0,0 @@
class CreditcardLastFourDigits < ActiveRecord::Migration
def up
rename_column :creditcards, :display_number, :last_digits
creditcards = select_all "SELECT * FROM creditcards"
creditcards.each do |card|
execute "UPDATE creditcards SET last_digits = '#{card['last_digits'].gsub('XXXX-XXXX-XXXX-', '')}' WHERE id = #{card['id']}" if card['last_digits'].present?
end
end
def down
rename_column :creditcards, :last_digits, :display_number
end
end

View File

@@ -1,15 +0,0 @@
class PopulateLegacyShipmentState < ActiveRecord::Migration
def up
shipments = select_all "SELECT * FROM shipments"
shipments.each do |shipment|
if shipment['shipped_at']
execute "UPDATE shipments SET state = 'shipped'"
else
execute "UPDATE shipments SET state = 'pending'"
end
end
end
def down
end
end

View File

@@ -1,5 +0,0 @@
class AddCostPrice < ActiveRecord::Migration
def change
add_column :variants, :cost_price, :decimal, :null => true, :default => nil, :precision => 8, :scale => 2
end
end

View File

@@ -1,25 +0,0 @@
class ShipmentIdForInventoryUnits < ActiveRecord::Migration
def up
add_column :inventory_units, :shipment_id, :integer
add_index :inventory_units, :shipment_id
# migrate legacy shipments
Spree::Shipment.table_name = 'shipments'
Spree::Shipment.all.each do |shipment|
unless shipment.order
puts "Warning: shipment has invalid order - #{shipment.id}"
next
end
shipment.order.inventory_units.each do |unit|
unit.update_attribute('shipment_id', shipment.id)
end
end
Spree::Shipment.table_name = 'spree_shipments'
end
def down
remove_column :inventory_units, :shipment_id
end
end

View File

@@ -1,6 +0,0 @@
class CimFieldsForCreditcards < ActiveRecord::Migration
def change
add_column :creditcards, :gateway_customer_profile_id, :string
add_column :creditcards, :gateway_payment_profile_id, :string
end
end

View File

@@ -1,12 +0,0 @@
class CreateReturnAuthorizations < ActiveRecord::Migration
def change
create_table :return_authorizations do |t|
t.string :number, :state
t.decimal :amount, :precision => 8, :scale => 2, :default => 0.0, :null => false
t.references :order
t.text :reason
t.timestamps
end
end
end

View File

@@ -1,5 +0,0 @@
class AddReturnAuthorizationToInventoryUnits < ActiveRecord::Migration
def change
add_column :inventory_units, :return_authorization_id, :integer
end
end

View File

@@ -1,10 +0,0 @@
class CreateTrackers < ActiveRecord::Migration
def change
create_table :trackers do |t|
t.string :environment, :analytics_id
t.boolean :active, :default => true
t.timestamps
end
end
end

View File

@@ -1,5 +0,0 @@
class CreditcardIdForCreditcardTxns < ActiveRecord::Migration
def change
add_column :creditcard_txns, :creditcard_id, :integer
end
end

View File

@@ -1,5 +0,0 @@
class OriginalCreditcardTxnIdForCreditcardTxns < ActiveRecord::Migration
def change
add_column :creditcard_txns, :original_creditcard_txn_id, :integer
end
end

View File

@@ -1,6 +0,0 @@
class AddTestModeToBillingIntegration < ActiveRecord::Migration
def change
add_column :billing_integrations, :test_mode, :boolean, :default => true
add_column :billing_integrations, :server, :string, :default => 'test'
end
end

View File

@@ -1,8 +0,0 @@
class CreateProductsProductGroups < ActiveRecord::Migration
def change
create_table :product_groups_products, :id => false do |t|
t.references :product
t.references :product_group
end
end
end

View File

@@ -1,16 +0,0 @@
class CreatePaymentMethods < ActiveRecord::Migration
def change
create_table :payment_methods do |t|
t.string :type, :name
t.text :description
t.boolean :active, :default => true
t.string :environment, :default => 'development'
t.timestamps
end
# TODO - also migrate any legacy configurations for gateways and billing integrations before dropping the old tables
# we probably also need to do this inside the payment_gateway extension b/c table won't exist yet in fresh bootstrap
#drop_table :billing_integrations
#drop_table :gateways
end
end

View File

@@ -1,43 +0,0 @@
# Legacy table support
class Checkout < ActiveRecord::Base; end;
class Spree::Creditcard < ActiveRecord::Base; end;
class PolymorphicPayments < ActiveRecord::Migration
def up
remove_column :payments, :type
remove_column :payments, :creditcard_id
rename_column :payments, :order_id, :payable_id
change_table :payments do |t|
t.string :payable_type, :payment_method
t.references :source, :polymorphic => true
end
execute "UPDATE payments SET payable_type = 'Order'"
Spree::Creditcard.table_name = 'creditcards'
Spree::Creditcard.all.each do |creditcard|
if checkout = Checkout.find_by_id(creditcard.checkout_id) and checkout.order
if payment = checkout.order.payments.first
execute "UPDATE payments SET source_type = 'Creditcard', source_id = #{creditcard.id} WHERE id = #{payment.id}"
end
end
end
Spree::Creditcard.table_name = 'spree_creditcards'
remove_column :creditcards, :checkout_id
end
def down
add_column :creditcards, :checkout_id, :integer
change_table :payments do |t|
t.remove :payable_type
t.remove :payment_method
t.remove :source_id
t.remove :source_type
end
rename_column :payments, :payable_id, :order_id
add_column :payments, :creditcard_id, :integer
add_column :payments, :type, :string
end
end

View File

@@ -1,11 +0,0 @@
class ChangePaymentsPaymentMethodToBelongsTo < ActiveRecord::Migration
def up
remove_column :payments, :payment_method
add_column :payments, :payment_method_id, :integer
end
def down
add_column :payments, :payment_method, :string
remove_column :payments, :payment_method_id
end
end

View File

@@ -1,23 +0,0 @@
class AssignCreditcardTxnsToPayment < ActiveRecord::Migration
def up
add_column :creditcard_txns, :payment_id, :integer
# Temporarily set back to creditcards
Spree::Creditcard.table_name = 'creditcards'
ActiveRecord::Base.connection.select_all('SELECT * FROM creditcard_txns').each do |txn_attrs|
if creditcard = Spree::Creditcard.find_by_id(txn_attrs['creditcard_id']) and creditcard.payments.first
execute "UPDATE creditcard_txns SET payment_id = #{creditcard.payments.first.id} WHERE id = #{txn_attrs['id']}"
end
end
Spree::Creditcard.table_name = 'spree_creditcards'
remove_column :creditcard_txns, :creditcard_payment_id
end
def down
remove_column :creditcard_txns, :payment_id
add_column :creditcard_txns, :creditcard_payment_id, :integer
end
end

View File

@@ -1,15 +0,0 @@
class StiForTransactions < ActiveRecord::Migration
def up
rename_table :creditcard_txns, :transactions
add_column :transactions, :type, :string
remove_column :transactions, :creditcard_id
execute "UPDATE transactions SET type = 'CreditcardTxn'"
end
def down
rename_table :transactions, :creditcard_txns
remove_column :transactions, :type
add_column :transactions, :creditcard_id, :integer
end
end

View File

@@ -1,16 +0,0 @@
class DropBillingIntegrations < ActiveRecord::Migration
def up
drop_table :billing_integrations
end
def down
create_table :billing_integrations do |t|
t.string :type, :name
t.text :description
t.boolean :active, :default => true
t.string :environment, :default => 'development'
t.timestamps
end
end
end

View File

@@ -1,14 +0,0 @@
class DeletedAtForPaymentMethods < ActiveRecord::Migration
def up
change_table :payment_methods do |t|
t.timestamp :deleted_at, :default => nil
end
end
def down
remove_column :payments_methods, :column_name
change_table :payment_methods do |t|
t.remove :deleted_at
end
end
end

View File

@@ -1,6 +0,0 @@
class AddAdjustmentsIndex < ActiveRecord::Migration
def change
add_index :adjustments, :order_id
end
end

View File

@@ -1,9 +0,0 @@
class FixByPopularity < ActiveRecord::Migration
def up
execute("UPDATE product_scopes SET name='descend_by_popularity' WHERE name='by_popularity'")
end
def down
execute("UPDATE product_scopes SET name='by_popularity' WHERE name='descend_by_popularity'")
end
end

View File

@@ -1,5 +0,0 @@
class AddAltTextToImages < ActiveRecord::Migration
def change
add_column :assets, :alt, :text
end
end

View File

@@ -1,13 +0,0 @@
class Adjustment < ActiveRecord::Base; end;
class FixExistingCouponCredits < ActiveRecord::Migration
def up
execute("UPDATE adjustments SET type='PromotionCredit' WHERE type='CouponCredit'")
execute("UPDATE adjustments SET adjustment_source_type='Promotion' WHERE adjustment_source_type='Coupon'")
end
def down
execute("UPDATE adjustments SET adjustment_source_type='Coupon' WHERE adjustment_source_type='Promotion'")
execute("UPDATE adjustments SET type='CouponCredit' WHERE type='PromotionCredit'")
end
end

View File

@@ -1,5 +0,0 @@
class AddDisplayToPaymentMethods < ActiveRecord::Migration
def change
add_column :payment_methods, :display, :string, :default => nil
end
end

View File

@@ -1,8 +0,0 @@
class AddAddressesCheckoutsIndexes < ActiveRecord::Migration
def change
add_index :addresses, :firstname
add_index :addresses, :lastname
add_index :checkouts, :order_id
add_index :checkouts, :bill_address_id
end
end

View File

@@ -1,17 +0,0 @@
class AddIconToTaxons < ActiveRecord::Migration
def up
# skip this migration if the attribute already exists because of advanced taxon extension
return if column_exists?(:taxons, :icon_file_name)
add_column :taxons, :icon_file_name, :string
add_column :taxons, :icon_content_type, :string
add_column :taxons, :icon_file_size, :integer
add_column :taxons, :icon_updated_at, :datetime
end
def down
remove_column :taxons, :icon_file_name
remove_column :taxons, :icon_content_type
remove_column :taxons, :icon_file_size
remove_column :taxons, :icon_updated_at
end
end

View File

@@ -1,11 +0,0 @@
class AddDescriptionToTaxons < ActiveRecord::Migration
def up
# skip this migration if the attribute already exists because of advanced taxon extension
return if column_exists?(:taxons, :description)
add_column :taxons, :description, :text
end
def down
remove_column :taxons, :description
end
end

View File

@@ -1,5 +0,0 @@
class IndexForShipmentsNumber < ActiveRecord::Migration
def change
add_index :shipments, :number
end
end

View File

@@ -1,5 +0,0 @@
class AddIndexOnUsersPersistenceToken < ActiveRecord::Migration
def change
add_index :users, :persistence_token
end
end

View File

@@ -1,5 +0,0 @@
class AddDefaultToTaxCategories < ActiveRecord::Migration
def change
add_column :tax_categories, :is_default, :boolean, :default => false
end
end

View File

@@ -1,5 +0,0 @@
class AddDisplayToShippingMethods < ActiveRecord::Migration
def change
add_column :shipping_methods, :display_on, :string, :default => nil
end
end

View File

@@ -1,5 +0,0 @@
class RenamePaymentMethodDisplay < ActiveRecord::Migration
def change
rename_column :payment_methods, :display, :display_on
end
end

View File

@@ -1,5 +0,0 @@
class RenamePreferencesField < ActiveRecord::Migration
def change
rename_column :preferences, :attribute, :name
end
end

View File

@@ -1,5 +0,0 @@
class AddGuestFlag < ActiveRecord::Migration
def change
add_column :users, :guest, :boolean
end
end

View File

@@ -1,9 +0,0 @@
class DropOrderToken < ActiveRecord::Migration
def up
remove_column :orders, :token
end
def down
add_column :orders, :token, :string
end
end

View File

@@ -1,14 +0,0 @@
class PaymentsStateAndAssignedToOrderOnly < ActiveRecord::Migration
def up
# TODO: migrate existing payments
rename_column :payments, :payable_id, :order_id
remove_column :payments, :payable_type
add_column :payments, :state, :string
end
def down
remove_column :payments, :state
add_column :payments, :payable_type, :string
rename_column :payments, :order_id, :payable_id
end
end

View File

@@ -1,6 +0,0 @@
class CreateAddressKeysForOrder < ActiveRecord::Migration
def change
add_column :orders, :bill_address_id, :integer
add_column :orders, :ship_address_id, :integer
end
end

View File

@@ -1,5 +0,0 @@
class PaymentTotalForOrders < ActiveRecord::Migration
def change
add_column :orders, :payment_total, :decimal, :precision => 8, :scale => 2, :default => 0.0
end
end

View File

@@ -1,5 +0,0 @@
class ShippingMethodIdForOrders < ActiveRecord::Migration
def change
add_column :orders, :shipping_method_id, :integer
end
end

View File

@@ -1,6 +0,0 @@
class AddShipmentAndPaymentState < ActiveRecord::Migration
def change
add_column :orders, :shipment_state, :string
add_column :orders, :payment_state, :string
end
end

View File

@@ -1,29 +0,0 @@
class RefactorAdjustments < ActiveRecord::Migration
def up
change_table :adjustments do |t|
t.boolean :mandatory
t.boolean :frozen
t.rename :adjustment_source_id, :source_id
t.rename :adjustment_source_type, :source_type
t.references :originator
t.string :originator_type
t.remove :type
t.rename :description, :label
t.remove :position
end
end
def down
change_table :adjustments do |t|
t.integer :position
t.rename :label, :description
t.string :type
t.remove :originator_type
t.remove :originator_id
t.rename :source_type, :adjustment_source_type
t.rename :source_id, :adjustment_source_id
t.remove :frozen
t.remove :mandatory
end
end
end

View File

@@ -1,6 +0,0 @@
class ResponseCodeAndAvsResponseForPayments < ActiveRecord::Migration
def change
add_column :payments, :response_code, :string
add_column :payments, :avs_response, :string
end
end

View File

@@ -1,5 +0,0 @@
class ChangeGuestFlagToAnonymous < ActiveRecord::Migration
def change
rename_column :users, :guest, :anonymous
end
end

View File

@@ -1,5 +0,0 @@
class EmailForOrders < ActiveRecord::Migration
def change
add_column :orders, :email, :string
end
end

View File

@@ -1,10 +0,0 @@
class CreateMailMethods < ActiveRecord::Migration
def change
create_table :mail_methods do |t|
t.string :environment
t.boolean :active, :default => true
t.timestamps
end
end
end

View File

@@ -1,5 +0,0 @@
class RenameFrozenToLocked < ActiveRecord::Migration
def change
rename_column :adjustments, :frozen, :locked
end
end

View File

@@ -1,10 +0,0 @@
class MoveSpecialInstructionsToOrders < ActiveRecord::Migration
def up
add_column :orders, :special_instructions, :text
execute "UPDATE orders SET special_instructions = (SELECT special_instructions FROM checkouts WHERE order_id = orders.id)"
end
def down
remove_column :orders, :special_instructions, :text
end
end

View File

@@ -1,11 +0,0 @@
class CreateLogEntries < ActiveRecord::Migration
def change
create_table :log_entries do |t|
t.integer :source_id
t.string :source_type
t.text :details
t.timestamps
end
end
end

View File

@@ -1,98 +0,0 @@
class Transaction < ActiveRecord::Base; end
class CreditcardTxn < Transaction; end
class MigrateTransactionsToPaymentState < ActiveRecord::Migration
AUTHORIZED=1
COMPLETED=2
PURCHASED=3
VOIDED = 4
CREDITED =5
PAYMENT_COMPLETE = 'completed'
PAYMENT_VOID = 'void'
PAYMENT_PENDING = 'pending'
# Temporarily set the table back to payments
Spree::Payment.table_name = 'payments'
def up
migrate_authorized_only_transactions
migrate_voided_transactions
migrate_completed_transactions
migrate_purchased_transactions
migrate_credited_transactions
Spree::Payment.table_name = 'spree_payments'
end
def migrate_credited_transactions
credited = Transaction.find_by_sql("SELECT * FROM transactions WHERE txn_type = #{CREDITED}")
credited.each do |tx|
payment = Spree::Payment.find(tx)
order = payment.order
order.create_payment(
:amount => tx.amount,
:source_id => payment.source_id, :source_type => 'Creditcard',
:payment_method_id => payment.payment_method_id, :state => PAYMENT_COMPLETE,
:avs_response => tx.avs_response, :response_code => tx.response_code
)
end
credited.each { |rec| rec.destroy }
end
def migrate_voided_transactions
voided = Transaction.find_by_sql("SELECT * FROM transactions WHERE txn_type = #{VOIDED}")
voided.each do |tx|
update_payment(tx, PAYMENT_VOID)
end
unless voided.empty?
all_but_credited = [AUTHORIZED, COMPLETED, PURCHASED, VOIDED]
voided_and_subsequent_transactions = Transaction.find_by_sql("SELECT * FROM transactions WHERE payment_id IN (#{voided.map(&:payment_id).join(',')}) AND txn_type IN (#{all_but_credited.join(',')})")
voided_and_subsequent_transactions.each { |rec| rec.destroy }
end
end
def migrate_purchased_transactions
migrate_transactions(PURCHASED)
end
def migrate_completed_transactions
migrate_transactions(COMPLETED)
end
def migrate_transactions(type)
txs = Transaction.find_by_sql("SELECT * FROM transactions WHERE txn_type = #{type}")
txs.each do |tx|
update_payment(tx, PAYMENT_COMPLETE)
end
txs.each { |rec| rec.destroy }
end
def migrate_authorized_only_transactions
if (ActiveRecord::Base.connection.adapter_name == 'PostgreSQL')
group_by_clause = 'GROUP BY transactions.' + Transaction.column_names.join(', transactions.')
else
group_by_clause = 'GROUP BY payment_id'
end
authorized_only = Transaction.find_by_sql("SELECT * FROM transactions #{group_by_clause} HAVING COUNT(payment_id) = 1 AND txn_type = #{AUTHORIZED}")
authorized_only.each do |tx|
update_payment(tx, PAYMENT_PENDING)
end
authorized_only.each { |rec| rec.destroy }
end
def update_payment(tx, state)
payment = Spree::Payment.find(tx.payment_id)
payment.update_attributes_without_callbacks({
:state => state,
:source_type => 'Creditcard',
:amount => tx.amount,
:response_code => tx.response_code,
:avs_response => tx.avs_response
})
end
def down
end
end

View File

@@ -1,19 +0,0 @@
class DeleteInProgressOrders < ActiveRecord::Migration
def up
execute("DELETE FROM orders WHERE orders.state = 'in_progress'")
delete_orphans('adjustments')
delete_orphans('checkouts')
delete_orphans('shipments')
delete_orphans('payments')
delete_orphans('line_items')
delete_orphans('inventory_units')
end
def down
end
private
def delete_orphans(table_name)
execute "DELETE FROM #{table_name} WHERE order_id NOT IN (SELECT id FROM orders)"
end
end

View File

@@ -1,23 +0,0 @@
class MigrateCheckoutToOrders < ActiveRecord::Migration
def up
orders = select_all "SELECT * FROM orders"
orders.each do |order|
checkout = update_order(order)
execute "DELETE FROM checkouts WHERE id = #{checkout['id']}" if checkout
end
end
def down
end
private
def update_order(order)
checkout = select_one "SELECT * FROM checkouts WHERE order_id = #{order['id']}"
if checkout
execute "UPDATE orders SET email='#{checkout['email']}', bill_address_id = #{checkout['bill_address_id']}, ship_address_id = #{checkout['ship_address_id']} WHERE id = #{checkout['id']}"
end
checkout
end
end

View File

@@ -1,12 +0,0 @@
class RemoveShippedState < ActiveRecord::Migration
def up
execute "UPDATE orders SET state = 'complete' WHERE state = 'shipped'"
shipments = select_all "SELECT shipments.id FROM shipments WHERE order_id IN (SELECT orders.id FROM orders WHERE orders.state = 'shipped')"
shipments.each do |shipment|
execute "UPDATE shipments SET state='shipped' WHERE id = #{shipment[:id]}"
end
end
def down
end
end

View File

@@ -1,8 +0,0 @@
class PreventNilPaymentTotal < ActiveRecord::Migration
def up
execute "UPDATE orders SET payment_total = 0.0 WHERE payment_total IS NULL"
end
def down
end
end

View File

@@ -1,9 +0,0 @@
class PreventNilEmail < ActiveRecord::Migration
def up
execute "UPDATE orders SET email = 'guest@example.com' WHERE email IS NULL"
execute "UPDATE orders SET email = 'guest@example.com' WHERE email = ''"
end
def down
end
end

View File

@@ -1,20 +0,0 @@
class GenerateAnonymousUsers < ActiveRecord::Migration
def up
Spree::User.table_name = 'users'
Spree::Order.table_name = 'orders'
Spree::User.reset_column_information
Spree::Order.where(:user_id => nil).each do |order|
user = Spree::User.anonymous!
user.email ||= order.email
order.user = user
order.save!
end
Spree::User.table_name = 'spree_users'
Spree::Order.table_name = 'spree_orders'
end
def down
end
end

View File

@@ -1,12 +0,0 @@
class UpdateOrderState < ActiveRecord::Migration
def up
Spree::Order.table_name = 'orders'
Spree::Order.all.map(&:update!)
Spree::Order.table_name = 'spree_orders'
end
def down
end
end

View File

@@ -1,11 +0,0 @@
class CleanupLegacyTables < ActiveRecord::Migration
def up
drop_table :checkouts
drop_table :transactions
drop_table :open_id_authentication_associations
drop_table :open_id_authentication_nonces
end
def down
end
end

View File

@@ -1,11 +0,0 @@
class RemoveNumberAndCvvFromCredicard < ActiveRecord::Migration
def up
remove_column :creditcards, :number
remove_column :creditcards, :verification_value
end
def down
add_column :creditcards, :verification_value, :text
add_column :creditcards, :number, :text
end
end

View File

@@ -1,9 +0,0 @@
class DropAnonymousFieldForUser < ActiveRecord::Migration
def up
remove_column :users, :anonymous
end
def down
add_column :users, :anonymous, :boolean
end
end

View File

@@ -1,9 +0,0 @@
class RenamedRmaCancelledState < ActiveRecord::Migration
def up
execute "UPDATE return_authorizations SET state = 'canceled' WHERE state = 'cancelled'"
end
def down
execute "UPDATE return_authorizations SET state = 'cancelled' WHERE state = 'canceled'"
end
end

View File

@@ -1,13 +0,0 @@
class FixProblematicIndexNames < ActiveRecord::Migration
def up
begin
remove_index :preferences, :name => 'index_preferences_on_owner_and_attribute_and_preference'
rescue ArgumentError
# ignore - already remove then
end
add_index :preferences, [:owner_id, :owner_type, :name, :group_id, :group_type], :name => 'ix_prefs_on_owner_attr_pref', :unique => true
end
def down
end
end

View File

@@ -1,5 +0,0 @@
class AddPositionToVariants < ActiveRecord::Migration
def change
add_column :variants, :position, :integer
end
end

View File

@@ -1,5 +0,0 @@
class AddNextStateToStateEvents < ActiveRecord::Migration
def change
add_column :state_events, :next_state, :string
end
end

View File

@@ -1,5 +0,0 @@
class AddPositionToOptionTypes < ActiveRecord::Migration
def change
add_column :option_types, :position, :integer, :null => false, :default => 0
end
end

View File

@@ -1,19 +0,0 @@
class RemoveTrailingSlashesInTaxonPermalinks < ActiveRecord::Migration
def up
taxons = select_all "SELECT * FROM taxons"
taxons.each do |taxon|
if taxon['permalink'] && taxon['permalink'][-1..-1] == '/'
execute "UPDATE taxons SET permalink = '#{taxon['permalink'][0...-1]}' WHERE id = #{taxon['id']}"
end
end
end
def down
taxons = select_all "SELECT * FROM taxons"
taxons.each do |taxon|
if taxon['permalink'] && taxon['permalink'][-1..-1] != '/'
execute "UPDATE taxons SET permalink = '#{taxon['permalink'] + '/'}' WHERE id = #{taxon['id']}"
end
end
end
end

View File

@@ -1,14 +0,0 @@
class CreateActivators < ActiveRecord::Migration
def change
create_table :activators, :force => true do |t|
t.string :description
t.datetime :expires_at
t.datetime :created_at
t.datetime :updated_at
t.datetime :starts_at
t.string :name
t.string :event_name
t.string :type
end
end
end

View File

@@ -1,5 +0,0 @@
class EligibleForAdjustments < ActiveRecord::Migration
def change
add_column :adjustments, :eligible, :boolean, :default => true
end
end

View File

@@ -1,52 +0,0 @@
class NamespaceTopLevelModels < ActiveRecord::Migration
def change
rename_table :activators, :spree_activators
rename_table :addresses, :spree_addresses
rename_table :adjustments, :spree_adjustments
rename_table :configurations, :spree_configurations
rename_table :assets, :spree_assets
rename_table :calculators, :spree_calculators
rename_table :countries, :spree_countries
rename_table :creditcards, :spree_creditcards
rename_table :gateways, :spree_gateways
rename_table :inventory_units, :spree_inventory_units
rename_table :line_items, :spree_line_items
rename_table :log_entries, :spree_log_entries
rename_table :mail_methods, :spree_mail_methods
rename_table :option_types, :spree_option_types
rename_table :option_values, :spree_option_values
rename_table :option_types_prototypes, :spree_option_types_prototypes
rename_table :option_values_variants, :spree_option_values_variants
rename_table :orders, :spree_orders
rename_table :payments, :spree_payments
rename_table :payment_methods, :spree_payment_methods
rename_table :preferences, :spree_preferences
rename_table :products, :spree_products
rename_table :product_groups, :spree_product_groups
rename_table :product_groups_products, :spree_product_groups_products
rename_table :product_option_types, :spree_product_option_types
rename_table :product_properties, :spree_product_properties
rename_table :product_scopes, :spree_product_scopes
rename_table :products_taxons, :spree_products_taxons
rename_table :properties, :spree_properties
rename_table :prototypes, :spree_prototypes
rename_table :properties_prototypes, :spree_properties_prototypes
rename_table :return_authorizations, :spree_return_authorizations
rename_table :roles, :spree_roles
rename_table :roles_users, :spree_roles_users
rename_table :shipments, :spree_shipments
rename_table :shipping_categories, :spree_shipping_categories
rename_table :shipping_methods, :spree_shipping_methods
rename_table :states, :spree_states
rename_table :state_events, :spree_state_events
rename_table :tax_categories, :spree_tax_categories
rename_table :tax_rates, :spree_tax_rates
rename_table :taxons, :spree_taxons
rename_table :taxonomies, :spree_taxonomies
rename_table :trackers, :spree_trackers
rename_table :users, :spree_users
rename_table :variants, :spree_variants
rename_table :zones, :spree_zones
rename_table :zone_members, :spree_zone_members
end
end

View File

@@ -1,52 +0,0 @@
class MigrateNamespacedPolymorphicModels < ActiveRecord::Migration
def concat(str1, str2)
dbtype = Rails.configuration.database_configuration[Rails.env]['adapter'].to_sym
case dbtype
when :mysql, :mysql2
"CONCAT(#{str1}, #{str2})"
when :sqlserver
"(#{str1} + #{str2})"
else
"(#{str1} || #{str2})"
end
end
def update_column_data(table_names, column_name)
tables = Array.wrap(table_names)
tables.each do |table|
execute "UPDATE #{table} SET #{column_name} = #{concat("'Spree::'", column_name)}" +
" where #{column_name} NOT LIKE 'Spree::%' AND #{column_name} IS NOT NULL"
end
end
def replace_column_data(table_names, column_name)
tables = Array.wrap(table_names)
tables.each do |table|
execute "UPDATE #{table} SET #{column_name} = REPLACE(#{column_name}, 'Spree::', '') " +
" where #{column_name} LIKE 'Spree::%'"
end
end
def up
update_column_data(['spree_payments', 'spree_adjustments', 'spree_log_entries'], 'source_type')
update_column_data('spree_adjustments', 'originator_type')
update_column_data('spree_calculators', 'calculable_type')
update_column_data('spree_preferences', 'owner_type')
update_column_data('spree_state_events', 'stateful_type')
update_column_data(['spree_activators', 'spree_assets', 'spree_calculators', 'spree_configurations', 'spree_gateways', 'spree_payment_methods'], 'type')
update_column_data('spree_assets', 'viewable_type')
update_column_data('spree_zone_members', 'zoneable_type')
end
def down
replace_column_data(['spree_payments', 'spree_adjustments', 'spree_log_entries'], 'source_type')
replace_column_data('spree_adjustments', 'originator_type')
replace_column_data('spree_calculators', 'calculable_type')
replace_column_data('spree_preferences', 'owner_type')
replace_column_data('spree_state_events', 'stateful_type')
replace_column_data(['spree_activators', 'spree_assets', 'spree_calculators', 'spree_configurations', 'spree_gateways', 'spree_payment_methods'], 'type')
replace_column_data('spree_assets', 'viewable_type')
replace_column_data('spree_zone_members', 'zoneable_type')
end
end

View File

@@ -1,9 +0,0 @@
class MakeAdjustmentsPolymorphic < ActiveRecord::Migration
def change
add_column :spree_adjustments, :adjustable_type, :string
rename_column :spree_adjustments, :order_id, :adjustable_id
execute "UPDATE spree_adjustments SET adjustable_type = 'Spree::Order'"
end
end

View File

@@ -1,5 +0,0 @@
class AddCompanyToAddresses < ActiveRecord::Migration
def change
add_column :spree_addresses, :company, :string
end
end

View File

@@ -1,5 +0,0 @@
class AddIncTaxToTaxRates < ActiveRecord::Migration
def change
add_column :spree_tax_rates, :inc_tax, :boolean, :default => false
end
end

View File

@@ -1,5 +0,0 @@
class RenameIncPriceAttribute < ActiveRecord::Migration
def change
rename_column :spree_tax_rates, :inc_tax, :included_in_price
end
end

View File

@@ -1,5 +0,0 @@
class AddDefaultTaxZone < ActiveRecord::Migration
def change
add_column :spree_zones, :default_tax, :boolean, :default => false
end
end

View File

@@ -1,7 +0,0 @@
class AssociateShippingMethodsAndShippingCategories < ActiveRecord::Migration
def change
change_table :spree_shipping_methods do |t|
t.references :shipping_category
end
end
end

View File

@@ -1,7 +0,0 @@
class AddMatchRulesToShippingMethods < ActiveRecord::Migration
def change
add_column :spree_shipping_methods, :match_none, :boolean
add_column :spree_shipping_methods, :match_all, :boolean
add_column :spree_shipping_methods, :match_one, :boolean
end
end

View File

@@ -1,81 +0,0 @@
# Spree 1.3.6.beta preference rescue implementation, required for the new
# preferences migration, which is broken since commit ab707cf due to the
# absence of this file.
#
# Migration: db/migrate/20120327000645_new_preferences.rb
# Source: https://raw.githubusercontent.com/spree/spree/1-3-stable/core/lib/spree/core/preference_rescue.rb
#
# rubocop:disable all
module Spree
class OldPrefs < ActiveRecord::Base
self.table_name = "spree_preferences"
belongs_to :owner, :polymorphic => true
attr_accessor :owner_klass
end
class PreferenceRescue
def self.try
OldPrefs.where(:key => nil).each do |old_pref|
next unless owner = (old_pref.owner rescue nil)
unless old_pref.owner_type == "Spree::Activator" || old_pref.owner_type == "Spree::Configuration"
begin
old_pref.key = [owner.class.name, old_pref.name, owner.id].join('::').underscore
old_pref.value_type = owner.preference_type(old_pref.name)
puts "Migrating Preference: #{old_pref.key}"
old_pref.save
rescue NoMethodError => ex
puts ex.message
end
end
end
end
end
end
# rubocop:enable all
class NewPreferences < ActiveRecord::Migration
def up
add_column :spree_preferences, :key, :string
add_column :spree_preferences, :value_type, :string
add_index :spree_preferences, :key, :unique => true
remove_index :spree_preferences, :name => 'ix_prefs_on_owner_attr_pref'
# remove old constraints for migration
change_column :spree_preferences, :name, :string, :null => true
change_column :spree_preferences, :owner_id, :integer, :null => true
change_column :spree_preferences, :owner_type, :string, :null => true
change_column :spree_preferences, :group_id, :integer, :null => true
change_column :spree_preferences, :group_type, :string, :null => true
cfgs = execute("select id, type from spree_configurations").to_a
execute("select id, owner_id, name from spree_preferences where owner_type = 'Spree::Configuration'").each do |pref|
configuration = cfgs.detect { |c| c[0].to_s == pref[1].to_s }
value_type = configuration[1].constantize.new.send "preferred_#{pref[2]}_type" rescue 'string'
execute "UPDATE spree_preferences set `key` = '#{configuration[1].underscore}/#{pref[2]}', `value_type` = '#{value_type}' where id = #{pref[0]}" rescue nil
end
# remove orphaned calculator preferences
Spree::Preference.where(:owner_type => 'Spree::Calculator').each do |preference|
preference.destroy unless Spree::Calculator.exists? preference.owner_id
end
Spree::PreferenceRescue.try
Spree::Preference.where(:value_type => nil).update_all(:value_type => 'string')
end
def down
remove_column :spree_preferences, :key
remove_column :spree_preferences, :value_type
add_column :spree_preferences, :name, :string
add_column :spree_preferences, :owner_id, :integer
add_column :spree_preferences, :owner_type, :string
add_column :spree_preferences, :group_id, :integer
add_column :spree_preferences, :group_type, :string
end
end

View File

@@ -1,5 +0,0 @@
class AddDeletedAtToTaxCategory < ActiveRecord::Migration
def change
add_column :spree_tax_categories, :deleted_at, :datetime
end
end

View File

@@ -1,39 +0,0 @@
class RenameColumnsForDevise < ActiveRecord::Migration
def up
return if column_exists?(:spree_users, :password_salt)
rename_column :spree_users, :crypted_password, :encrypted_password
rename_column :spree_users, :salt, :password_salt
rename_column :spree_users, :remember_token_expires_at, :remember_created_at
rename_column :spree_users, :login_count, :sign_in_count
rename_column :spree_users, :failed_login_count, :failed_attempts
rename_column :spree_users, :single_access_token, :reset_password_token
rename_column :spree_users, :current_login_at, :current_sign_in_at
rename_column :spree_users, :last_login_at, :last_sign_in_at
rename_column :spree_users, :current_login_ip, :current_sign_in_ip
rename_column :spree_users, :last_login_ip, :last_sign_in_ip
add_column :spree_users, :authentication_token, :string
add_column :spree_users, :unlock_token, :string
add_column :spree_users, :locked_at, :datetime
remove_column :spree_users, :api_key if column_exists?(:spree_users, :api_key)
remove_column :spree_users, :openid_identifier
end
def down
remove_column :spree_users, :authentication_token
remove_column :spree_users, :locked_at
remove_column :spree_users, :unlock_token
rename_column :table_name, :new_column_name, :column_name
rename_column :spree_users, :last_sign_in_ip, :last_login_ip
rename_column :spree_users, :current_sign_in_ip, :current_login_ip
rename_column :spree_users, :last_sign_in_at, :last_login_at
rename_column :spree_users, :current_sign_in_at, :current_login_at
rename_column :spree_users, :reset_password_token, :single_access_token
rename_column :spree_users, :failed_attempts, :failed_login_count
rename_column :spree_users, :sign_in_count, :login_count
rename_column :spree_users, :remember_created_at, :remember_token_expires_at
rename_column :spree_users, :password_salt, :salt
rename_column :spree_users, :encrypted_password, :crypted_password
add_column :spree_users, :unlock_token, :string
add_column :spree_users, :openid_identifier, :string
end
end

View File

@@ -1,11 +0,0 @@
class ConvertUserRememberField < ActiveRecord::Migration
def up
remove_column :spree_users, :remember_created_at
add_column :spree_users, :remember_created_at, :datetime
end
def down
remove_column :spree_users, :remember_created_at
add_column :spree_users, :remember_created_at, :string
end
end

View File

@@ -1,13 +0,0 @@
class CreateTokenizedPermissions < ActiveRecord::Migration
def change
create_table :tokenized_permissions do |t|
t.integer :permissable_id
t.string :permissable_type
t.string :token
t.timestamps
end
add_index :tokenized_permissions, [:permissable_id, :permissable_type], :name => 'index_tokenized_name_and_type'
end
end

View File

@@ -1,16 +0,0 @@
class TokensForLegacyOrders < ActiveRecord::Migration
def up
Spree::TokenizedPermission.table_name = 'tokenized_permissions'
# add token permissions for legacy orders (stop relying on user persistence token)
Spree::Order.all.each do |order|
next unless order.user
order.create_tokenized_permission(:token => order.user.persistence_token)
end
Spree::TokenizedPermission.table_name = 'spree_tokenized_permissions'
end
def down
end
end

View File

@@ -1,5 +0,0 @@
class NamespaceTokenizedPermission < ActiveRecord::Migration
def change
rename_table :tokenized_permissions, :spree_tokenized_permissions
end
end

Some files were not shown because too many files have changed in this diff Show More