Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Check column and index presence in db in filtrable for option types migration

Bogusław Tolarz4fe858c9d234
diff --git a/core/db/migrate/20201012091259_add_filterable_column_to_spree_option_types.rb b/core/db/migrate/20201012091259_add_filterable_column_to_spree_option_types.rb
index 264457338a..7748690eee 100644
--- a/core/db/migrate/20201012091259_add_filterable_column_to_spree_option_types.rb
+++ b/core/db/migrate/20201012091259_add_filterable_column_to_spree_option_types.rb
@@ -1,6 +1,10 @@
class AddFilterableColumnToSpreeOptionTypes < ActiveRecord::Migration[6.0]
def change
- add_column :spree_option_types, :filterable, :boolean, default: true, null: false
- add_index :spree_option_types, :filterable
+ unless column_exists?(:spree_option_types, :filterable)
+ add_column :spree_option_types, :filterable, :boolean, default: true, null: false
+ end
+ unless index_exists?(:spree_option_types, :filterable)
+ add_index :spree_option_types, :filterable
+ end
end
end