From bd48a982fbfb08e659155f5173d257f3bd2159cb Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 1 Aug 2024 13:56:48 +1000 Subject: [PATCH] Set connected apps as enabled if any Could have easily done this manually, but this makes the transition smoother. BTW I tested each case manually, didn't seem worth writing a spec. --- ...0801034710_set_connected_apps_enabled_if_any.rb | 14 ++++++++++++++ db/schema.rb | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20240801034710_set_connected_apps_enabled_if_any.rb diff --git a/db/migrate/20240801034710_set_connected_apps_enabled_if_any.rb b/db/migrate/20240801034710_set_connected_apps_enabled_if_any.rb new file mode 100644 index 0000000000..f1a3ef9140 --- /dev/null +++ b/db/migrate/20240801034710_set_connected_apps_enabled_if_any.rb @@ -0,0 +1,14 @@ +class SetConnectedAppsEnabledIfAny < ActiveRecord::Migration[7.0] + def up + enabled = [] + enabled << "discover_regen" if ConnectedApp.discover_regen.any? + enabled << "affiliate_sales_data" if ConnectedApp.affiliate_sales_data.any? + + Spree::Config.connected_apps_enabled = enabled.presence&.join(",") + end +end + +class ConnectedApp < ApplicationRecord + scope :discover_regen, -> { where(type: "ConnectedApp") } + scope :affiliate_sales_data, -> { where(type: "ConnectedApps::AffiliateSalesData") } +end diff --git a/db/schema.rb b/db/schema.rb index b1a239f42a..04013a7caf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2024_07_31_065321) do +ActiveRecord::Schema[7.0].define(version: 2024_08_01_034710) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" enable_extension "plpgsql"