Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e40fa8
commit 320757a
Showing
4 changed files
with
119 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# frozen_string_literal: true | ||
|
||
describe 'Ridgepole::Client#diff -> migrate', condition: [['>= 6.1', :mysql80]] do | ||
context 'when add check constraint' do | ||
let(:actual_dsl) do | ||
erbh(<<-ERB) | ||
create_table "salaries", id: false, force: :cascade do |t| | ||
t.integer "emp_no", null: false | ||
t.integer "salary", null: false | ||
t.date "from_date", null: false | ||
t.date "to_date", null: false | ||
end | ||
ERB | ||
end | ||
|
||
let(:expected_dsl) do | ||
erbh(<<-ERB) | ||
create_table "salaries", id: false, force: :cascade do |t| | ||
t.integer "emp_no", null: false | ||
t.integer "salary", null: false | ||
t.date "from_date", null: false | ||
t.date "to_date", null: false | ||
t.check_constraint "`salary` > 100", name: "salary_check" | ||
end | ||
ERB | ||
end | ||
|
||
before { subject.diff(actual_dsl).migrate } | ||
subject { client } | ||
|
||
it { | ||
delta = subject.diff(expected_dsl) | ||
expect(delta.differ?).to be_truthy | ||
expect(subject.dump).to match_ruby actual_dsl | ||
delta.migrate | ||
expect(subject.dump).to match_ruby expected_dsl | ||
} | ||
end | ||
end |
40 changes: 40 additions & 0 deletions
40
spec/mysql/migrate/migrate_change_check_constraint_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,40 @@ | ||
# frozen_string_literal: true | ||
|
||
describe 'Ridgepole::Client#diff -> migrate', condition: [['>= 6.1', :mysql80]] do | ||
context 'when add check constraint' do | ||
let(:actual_dsl) do | ||
erbh(<<-ERB) | ||
create_table "salaries", id: false, force: :cascade do |t| | ||
t.integer "emp_no", null: false | ||
t.integer "salary", null: false | ||
t.date "from_date", null: false | ||
t.date "to_date", null: false | ||
t.check_constraint "`salary` > 100", name: "salary_check" | ||
end | ||
ERB | ||
end | ||
|
||
let(:expected_dsl) do | ||
erbh(<<-ERB) | ||
create_table "salaries", id: false, force: :cascade do |t| | ||
t.integer "emp_no", null: false | ||
t.integer "salary", null: false | ||
t.date "from_date", null: false | ||
t.date "to_date", null: false | ||
t.check_constraint "`salary` > 200", name: "salary_check" | ||
end | ||
ERB | ||
end | ||
|
||
before { subject.diff(actual_dsl).migrate } | ||
subject { client } | ||
|
||
it { | ||
delta = subject.diff(expected_dsl) | ||
expect(delta.differ?).to be_truthy | ||
expect(subject.dump).to match_ruby actual_dsl | ||
delta.migrate | ||
expect(subject.dump).to match_ruby expected_dsl | ||
} | ||
end | ||
end |
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,39 @@ | ||
# frozen_string_literal: true | ||
|
||
describe 'Ridgepole::Client#diff -> migrate', condition: [['>= 6.1', :mysql80]] do | ||
context 'when add check constraint' do | ||
let(:actual_dsl) do | ||
erbh(<<-ERB) | ||
create_table "salaries", id: false, force: :cascade do |t| | ||
t.integer "emp_no", null: false | ||
t.integer "salary", null: false | ||
t.date "from_date", null: false | ||
t.date "to_date", null: false | ||
t.check_constraint "`salary` > 100", name: "salary_check" | ||
end | ||
ERB | ||
end | ||
|
||
let(:expected_dsl) do | ||
erbh(<<-ERB) | ||
create_table "salaries", id: false, force: :cascade do |t| | ||
t.integer "emp_no", null: false | ||
t.integer "salary", null: false | ||
t.date "from_date", null: false | ||
t.date "to_date", null: false | ||
end | ||
ERB | ||
end | ||
|
||
before { subject.diff(actual_dsl).migrate } | ||
subject { client } | ||
|
||
it { | ||
delta = subject.diff(expected_dsl) | ||
expect(delta.differ?).to be_truthy | ||
expect(subject.dump).to match_ruby actual_dsl | ||
delta.migrate | ||
expect(subject.dump).to match_ruby expected_dsl | ||
} | ||
end | ||
end |
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