Skip to content
代码片段 群组 项目
提交 4c6d2149 编辑于 作者: Leonardo Rosa's avatar Leonardo Rosa
浏览文件

Casts finalized_by migration version to an integer

When the finalized_by key is present in the BBM dictionary file,
the migration version should be cast as an integer, otherwise
ActiveRecord will fail to find the target version, and it will
throw an error.

https://gitlab.com/gitlab-org/gitlab/-/merge_requests/151467#note_1887895592

Changelog: fixed
上级 4fed4894
No related branches found
No related tags found
无相关合并请求
......@@ -121,8 +121,10 @@ def previous_migration(steps_back = 2)
end
def finalized_by_version
::Gitlab::Database::BackgroundMigration::BatchedBackgroundMigrationDictionary
finalized_by = ::Gitlab::Database::BackgroundMigration::BatchedBackgroundMigrationDictionary
.entry(described_class.to_s.demodulize)&.finalized_by
finalized_by.to_i if finalized_by
end
def migration_schema_version
......
......@@ -107,4 +107,30 @@
end
end
end
describe '#finalized_by_version' do
let(:dictionary_entry) { nil }
before do
allow(helper).to receive(:described_class)
allow(::Gitlab::Database::BackgroundMigration::BatchedBackgroundMigrationDictionary).to(
receive(:entry).and_return(dictionary_entry)
)
end
context 'when no dictionary was found' do
it { expect(helper.finalized_by_version).to be_nil }
end
context 'when finalized_by is a string' do
let(:dictionary_entry) do
instance_double(
::Gitlab::Database::BackgroundMigration::BatchedBackgroundMigrationDictionary::Entry,
finalized_by: '20240104155616'
)
end
it { expect(helper.finalized_by_version).to eq(20240104155616) }
end
end
end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册