fix(installation_config): normalize legacy native-hash rows to YAML strings
Some rows in installation_configs.serialized_value were written as native jsonb objects by older code paths, while the YAML coder expects JSON-encoded YAML strings. Reading the object-shaped rows raised "TypeError: no implicit conversion of Hash into String" in production after the upstream 4.13.0 merge. Convert every object-shaped row to the YAML-string shape the coder produces, so the stock serialize :serialized_value, coder: YAML, ... works for all rows without needing a custom coder.
This commit is contained in:
parent
97b71915aa
commit
9cb045f46f
@ -0,0 +1,25 @@
|
|||||||
|
class NormalizeInstallationConfigSerializedValues < ActiveRecord::Migration[7.1]
|
||||||
|
# Rails' YAML coder expects the jsonb column to hold a JSON-encoded YAML
|
||||||
|
# string. Some rows were written as native jsonb objects by older code paths,
|
||||||
|
# which raises "no implicit conversion of Hash into String" on read. Convert
|
||||||
|
# every `object`-shaped row to the YAML-string shape the coder produces.
|
||||||
|
def up
|
||||||
|
rows = execute(
|
||||||
|
"SELECT id, serialized_value FROM installation_configs WHERE jsonb_typeof(serialized_value) = 'object'"
|
||||||
|
).to_a
|
||||||
|
|
||||||
|
rows.each do |row|
|
||||||
|
hash = JSON.parse(row['serialized_value']).with_indifferent_access
|
||||||
|
yaml = YAML.dump(hash)
|
||||||
|
execute(
|
||||||
|
ActiveRecord::Base.sanitize_sql_array(
|
||||||
|
['UPDATE installation_configs SET serialized_value = to_jsonb(?::text) WHERE id = ?', yaml, row['id']]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
raise ActiveRecord::IrreversibleMigration
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[7.1].define(version: 2026_04_10_170003) do
|
ActiveRecord::Schema[7.1].define(version: 2026_04_18_020000) do
|
||||||
# These extensions should be enabled to support this database
|
# These extensions should be enabled to support this database
|
||||||
enable_extension "pg_stat_statements"
|
enable_extension "pg_stat_statements"
|
||||||
enable_extension "pg_trgm"
|
enable_extension "pg_trgm"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user