Skip to content

Commit 69d25a5

Browse files
authored
Merge pull request rails#38564 from kytrinyx/normalize-schema-cache-version-reset
Normalize resetting schema cache version for YAML and Marshal
2 parents bbec38b + 7febae4 commit 69d25a5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

activerecord/lib/active_record/connection_adapters/schema_cache.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ def initialize_dup(other)
3333
end
3434

3535
def encode_with(coder)
36+
reset_version!
37+
3638
coder["columns"] = @columns
3739
coder["primary_keys"] = @primary_keys
3840
coder["data_sources"] = @data_sources
3941
coder["indexes"] = @indexes
40-
coder["version"] = connection.migration_context.current_version
42+
coder["version"] = @version
4143
coder["database_version"] = database_version
4244
end
4345

@@ -149,8 +151,8 @@ def dump_to(filename)
149151
end
150152

151153
def marshal_dump
152-
# if we get current version during initialization, it happens stack over flow.
153-
@version = connection.migration_context.current_version
154+
reset_version!
155+
154156
[@version, @columns, {}, @primary_keys, @data_sources, @indexes, database_version]
155157
end
156158

@@ -162,6 +164,10 @@ def marshal_load(array)
162164
end
163165

164166
private
167+
def reset_version!
168+
@version = connection.migration_context.current_version
169+
end
170+
165171
def derive_columns_hash_and_deduplicate_values
166172
@columns = deep_deduplicate(@columns)
167173
@columns_hash = @columns.transform_values { |columns| columns.index_by(&:name) }

0 commit comments

Comments
 (0)