Skip to content

Commit

Permalink
Write migration for renamed COP cutoff input in quintel/etsource#3030
Browse files Browse the repository at this point in the history
  • Loading branch information
mabijkerk committed Apr 11, 2024
1 parent 080b7b0 commit d8199b8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions db/migrate/20240411112150_rename_cutoff_cop_input.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'etengine/scenario_migration'

class RenameCutoffCopInput < ActiveRecord::Migration[7.0]
include ETEngine::ScenarioMigration

KEYS = {
'flexibility_heat_pump_space_heating_cop_cutoff' => 'flexibility_heat_pump_space_heating_cop_cutoff_gas',
}.freeze

def up
migrate_scenarios do |scenario|
KEYS.each do |old_key, new_key|
if scenario.user_values.key?(old_key)
scenario.user_values[new_key] = scenario.user_values.delete(old_key)
end
end
end
end
end
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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_04_02_111604) do
ActiveRecord::Schema[7.0].define(version: 2024_04_11_112150) do
create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.string "name", limit: 191, null: false
t.string "record_type", limit: 191, null: false
Expand Down

0 comments on commit d8199b8

Please sign in to comment.