Skip to content

Commit

Permalink
Fix how optionals[:temporal] is handled
Browse files Browse the repository at this point in the history
Close #334
  • Loading branch information
pnomolos authored and tagliala committed Dec 6, 2024
1 parent 94ae442 commit dafba6f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 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 @@ -84,7 +84,7 @@ def change_table(table_name, **options, &block)
end

else
if is_chrono?(table_name)
if is_chrono?(table_name) && options[:temporal] == false
chrono_undo_temporal_table(table_name)
end

Expand Down
22 changes: 19 additions & 3 deletions spec/chrono_model/adapter/migrations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,27 @@

describe '.change_table' do
with_temporal_table do
before do
adapter.change_table table, temporal: false
context 'when explicitly requesting temporal: false' do
before do
adapter.change_table table, temporal: false
end

it_behaves_like 'plain table'
end

it_behaves_like 'plain table'
context 'when adding a column without specifying temporal: true' do
before do
adapter.change_table table do |t|
t.integer :new_column
end
end

it_behaves_like 'temporal table'

it { is_expected.to have_columns([%w[new_column integer]]) }
it { is_expected.to have_temporal_columns([%w[new_column integer]]) }
it { is_expected.to have_history_columns([%w[new_column integer]]) }
end
end

with_plain_table do
Expand Down

0 comments on commit dafba6f

Please sign in to comment.