Migrate all spree pref. keys to the new format

We realized in Spree v2.1 they follow this format instead and this is
what's causing issues to Katuma production.

This will remove the duplicate ones and convert the current preferences
to the new thus, keeping the values.
This commit is contained in:
Pau Perez
2020-06-23 16:17:25 +02:00
parent 973ea2ea2d
commit 0ffa7b3734
2 changed files with 12 additions and 1 deletions

View File

@@ -0,0 +1,11 @@
class FixPreferencesKeys < ActiveRecord::Migration
def up
new_preferences = Spree::Preference.where("key like '/%'")
new_preferences.delete_all
Spree::Preference.update_all("key = '/' || key")
end
def down
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20200508101630) do
ActiveRecord::Schema.define(version: 20200623140437) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"