Skip to content

Commit 7b266b9

Browse files
committed
Add migration to remove retired household behaviour keys for quintel/etmodel#4484
1 parent 69c7834 commit 7b266b9

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require 'etengine/scenario_migration'
2+
3+
class RemoveHouseholdBehaviour < ActiveRecord::Migration[7.1]
4+
include ETEngine::ScenarioMigration
5+
6+
# Retired household behaviour keys
7+
HOUSEHOLD_BEHAVIOUR_KEYS = %w[
8+
households_behavior_low_temperature_washing
9+
households_behavior_standby_killer_turn_off_appliances
10+
households_behavior_turn_off_the_light
11+
households_behavior_close_windows_turn_off_heating
12+
].freeze
13+
14+
def up
15+
migrate_scenarios do |scenario|
16+
17+
# Check if one of household behaviour keys has been set, then remove them
18+
next unless HOUSEHOLD_BEHAVIOUR_KEYS.any? { |key| scenario.user_values.key?(key)}
19+
20+
HOUSEHOLD_BEHAVIOUR_KEYS.each do |key|
21+
scenario.user_values.delete(key)
22+
end
23+
end
24+
end
25+
end

db/schema.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema[7.1].define(version: 2025_04_17_090853) do
13+
ActiveRecord::Schema[7.1].define(version: 2025_05_12_070901) do
1414
create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
1515
t.string "name", limit: 191, null: false
1616
t.string "record_type", limit: 191, null: false

0 commit comments

Comments
 (0)