Skip to content

Commit

Permalink
Update schema tests for rails/rails#45908
Browse files Browse the repository at this point in the history
After rails/rails#45908 we can no longer manipulate
the ar_schema_migrations table via the ActiveRecord::SchemaMigration class, go
through the default instance instead.
  • Loading branch information
dlagerro committed Feb 21, 2024
1 parent 211e3d1 commit e3d0368
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
Expand Up @@ -276,7 +276,7 @@ def drop_table(table_name, **options) # :nodoc:
end

def insert_versions_sql(versions) # :nodoc:
sm_table = quote_table_name(ActiveRecord::SchemaMigration.table_name)
sm_table = quote_table_name(ActiveRecord::Base.connection.schema_migration.table_name)

if supports_multi_insert?
versions.inject(+"INSERT ALL\n") { |sql, version|
Expand Down
Expand Up @@ -81,8 +81,8 @@ def fake_terminal(input)
describe "structure" do
let(:temp_file) { Tempfile.create(["oracle_enhanced", ".sql"]).path }
before do
ActiveRecord::SchemaMigration.create_table
ActiveRecord::Base.connection.execute "INSERT INTO schema_migrations (version) VALUES ('20150101010000')"
ActiveRecord::Base.connection.schema_migration.create_table
ActiveRecord::Base.connection.schema_migration.create_version("20150101010000")
end

describe "structure_dump" do
Expand All @@ -109,7 +109,7 @@ def fake_terminal(input)

after do
File.unlink(temp_file)
ActiveRecord::SchemaMigration.drop_table
ActiveRecord::Base.connection.schema_migration.drop_table
end
end

Expand Down
Expand Up @@ -1228,7 +1228,7 @@ class << @conn
before do
@conn = ActiveRecord::Base.connection

ActiveRecord::SchemaMigration.create_table
ActiveRecord::Base.connection.schema_migration.create_table
end

context "multi insert is supported" do
Expand Down Expand Up @@ -1256,7 +1256,7 @@ class << @conn
end

after do
ActiveRecord::SchemaMigration.drop_table
ActiveRecord::Base.connection.schema_migration.drop_table
end
end
end
Expand Up @@ -334,10 +334,9 @@ class ::TestPost < ActiveRecord::Base
let(:dump) { ActiveRecord::Base.connection.dump_schema_information }

before do
ActiveRecord::SchemaMigration.reset_table_name
ActiveRecord::SchemaMigration.create_table
ActiveRecord::Base.connection.schema_migration.create_table
versions.each do |i|
ActiveRecord::SchemaMigration.create!(version: i)
ActiveRecord::Base.connection.schema_migration.create_version(i)
end
end

Expand Down Expand Up @@ -377,7 +376,7 @@ class ::TestPost < ActiveRecord::Base
end

after do
ActiveRecord::SchemaMigration.drop_table
ActiveRecord::Base.connection.schema_migration.drop_table
end
end

Expand Down

0 comments on commit e3d0368

Please sign in to comment.