diff --git a/db/migrate/20260418020000_normalize_installation_config_serialized_values.rb b/db/migrate/20260418020000_normalize_installation_config_serialized_values.rb new file mode 100644 index 000000000..98b05779f --- /dev/null +++ b/db/migrate/20260418020000_normalize_installation_config_serialized_values.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 0fc367337..d3ab66a24 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.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 enable_extension "pg_stat_statements" enable_extension "pg_trgm"