Skip to content

Commit

Permalink
Merge pull request #139 from ifad/bugfix/fix-drop-table-with-options
Browse files Browse the repository at this point in the history
Fix drop_table with options migration
  • Loading branch information
tagliala authored Feb 13, 2022
2 parents 1361540 + 142f300 commit d9d4f8d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/chrono_model/adapter/migrations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def change_table(table_name, **options, &block)
# If dropping a temporal table, drops it from the temporal schema
# adding the CASCADE option so to delete the history, view and triggers.
#
def drop_table(table_name, *)
def drop_table(table_name, **options)
return super unless is_chrono?(table_name)

on_temporal_schema { execute "DROP TABLE #{table_name} CASCADE" }
Expand Down
29 changes: 21 additions & 8 deletions spec/chrono_model/adapter/migrations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,30 @@
end

describe '.drop_table' do
before :all do
adapter.create_table table, :temporal => true, &columns
context 'with temporal tables' do
before :all do
adapter.create_table table, :temporal => true, &columns

adapter.drop_table table
adapter.drop_table table
end

it { is_expected.to_not have_public_backing }
it { is_expected.to_not have_temporal_backing }
it { is_expected.to_not have_history_backing }
it { is_expected.to_not have_history_functions }
it { is_expected.to_not have_public_interface }
end

it { is_expected.to_not have_public_backing }
it { is_expected.to_not have_temporal_backing }
it { is_expected.to_not have_history_backing }
it { is_expected.to_not have_history_functions }
it { is_expected.to_not have_public_interface }
context 'without temporal tables' do
before :all do
adapter.create_table table, :temporal => false, &columns

adapter.drop_table table, :temporal => false
end

it { is_expected.to_not have_public_backing }
it { is_expected.to_not have_public_interface }
end
end

describe '.add_index' do
Expand Down

0 comments on commit d9d4f8d

Please sign in to comment.