-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix rename_table for compatibility migrations
- Loading branch information
1 parent
67fef7d
commit a1bc9d9
Showing
2 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
spec/active_record/connection_adapters/oracle_enhanced/compatibility_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
describe "compatibility migrations" do | ||
include SchemaSpecHelper | ||
|
||
before(:all) do | ||
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS) | ||
@conn = ActiveRecord::Base.connection | ||
schema_define do | ||
create_table :test_employees, force: true | ||
end | ||
end | ||
|
||
after(:all) do | ||
schema_define do | ||
drop_table :test_employees, if_exists: true | ||
drop_table :new_test_employees, if_exists: true | ||
end | ||
end | ||
|
||
it "should rename table on 7_0 and below" do | ||
migration = Class.new(ActiveRecord::Migration[7.0]) { | ||
def change | ||
rename_table :test_employees, :new_test_employees | ||
end | ||
}.new | ||
|
||
migration.migrate(:up) | ||
expect(@conn.table_exists?(:new_test_employees)).to be_truthy | ||
expect(@conn.table_exists?(:test_employees)).not_to be_truthy | ||
|
||
migration.migrate(:down) | ||
expect(@conn.table_exists?(:new_test_employees)).not_to be_truthy | ||
expect(@conn.table_exists?(:test_employees)).to be_truthy | ||
end | ||
end |