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.
This commit is contained in:
David Cook
2024-08-01 13:56:48 +10:00
committed by Rachel Arnould
parent 5d732d80a6
commit bd48a982fb
2 changed files with 15 additions and 1 deletions

View File

@@ -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

View File

@@ -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"