-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #251 from winebarrel/normalize_add_foreign_key_opt…
…ions Normalize add_foreign_key options
- Loading branch information
Showing
4 changed files
with
48 additions
and
4 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
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
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
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,45 @@ | ||
describe 'Ridgepole::Client#diff -> migrate' do | ||
context 'when change fk' do | ||
let(:actual_dsl) do | ||
erbh(<<-ERB) | ||
create_table "users", id: false, force: :cascade do |t| | ||
t.bigint :my_original_id, null: false | ||
t.index %i[my_original_id], unique: true | ||
end | ||
create_table "lessons", force: :cascade do |t| | ||
t.bigint :user_id2, null: false | ||
t.index %i[user_id2], name: :index_lessons_on_user_id2 | ||
end | ||
add_foreign_key :lessons, :users, primary_key: :my_original_id, column: :user_id2 | ||
ERB | ||
end | ||
|
||
let(:expected_dsl) do | ||
erbh(<<-ERB) | ||
create_table "lessons", force: :cascade do |t| | ||
t.bigint "user_id2", null: false | ||
t.index ["user_id2"], name: "index_lessons_on_user_id2", <%= i cond(5.0, using: :btree) %> | ||
end | ||
create_table "users", id: false, force: :cascade do |t| | ||
t.bigint "my_original_id", null: false | ||
t.index ["my_original_id"], name: "index_users_on_my_original_id", unique: true, <%= i cond(5.0, using: :btree) %> | ||
end | ||
add_foreign_key "lessons", "users", primary_key: "my_original_id", column: "user_id2" | ||
ERB | ||
end | ||
|
||
before { subject.diff(actual_dsl).migrate } | ||
|
||
subject { client } | ||
|
||
it { | ||
expect(subject.diff(actual_dsl).differ?).to be_falsey | ||
expect(subject.diff(expected_dsl).differ?).to be_falsey | ||
expect(subject.dump).to match_ruby expected_dsl | ||
} | ||
end | ||
end |