-
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 #36 from winebarrel/v0.5.2
v0.5.2
- Loading branch information
Showing
22 changed files
with
569 additions
and
249 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,7 @@ rvm: | |
script: | ||
- bundle install | ||
- bundle exec rake | ||
env: | ||
matrix: | ||
- ENABLE_MYSQL_AWESOME=0 | ||
- ENABLE_MYSQL_AWESOME=1 |
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
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,8 @@ | ||
# XXX: https://github.com/waka/activerecord-mysql-unsigned/blob/v0.3.1/lib/activerecord-mysql-unsigned/active_record/v3/connection_adapters/abstract/schema_definitions.rb#L14 | ||
class ActiveRecord::ConnectionAdapters::TableDefinition | ||
alias primary_key_without_unsigned primary_key | ||
|
||
def primary_key(name, type = :primary_key, options = {}) | ||
primary_key_without_unsigned(name, type, options.merge(primary_key: true).reverse_merge(unsigned: true)) | ||
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Ridgepole | ||
VERSION = '0.5.1' | ||
VERSION = '0.5.2.beta6' | ||
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
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,47 @@ | ||
if mysql_awesome_enabled? | ||
describe 'Ridgepole::Client (with bigint pk)' do | ||
let(:dsl1) { | ||
<<-RUBY | ||
create_table "books", id: :primary_key, limit: 8, force: true do |t| | ||
t.string "title", null: false | ||
t.integer "author_id", null: false | ||
t.datetime "created_at" | ||
t.datetime "updated_at" | ||
end | ||
RUBY | ||
} | ||
|
||
let(:dsl2) { | ||
<<-RUBY | ||
create_table "books", id: :bigint, force: true do |t| | ||
t.string "title", null: false | ||
t.integer "author_id", null: false | ||
t.datetime "created_at" | ||
t.datetime "updated_at" | ||
end | ||
RUBY | ||
} | ||
|
||
context 'when with limit:8' do | ||
subject { client } | ||
|
||
before { subject.diff(dsl1).migrate } | ||
|
||
it { | ||
expect(show_create_table(:books)).to include '`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT' | ||
expect(subject.dump).to eq dsl2.strip_heredoc.strip | ||
} | ||
end | ||
|
||
context 'when with id:bigint' do | ||
subject { client } | ||
|
||
before { subject.diff(dsl2).migrate } | ||
|
||
it { | ||
expect(show_create_table(:books)).to include '`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT' | ||
expect(subject.dump).to eq dsl2.strip_heredoc.strip | ||
} | ||
end | ||
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
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,132 @@ | ||
if mysql_awesome_enabled? | ||
describe 'Ridgepole::Client#diff -> migrate' do | ||
context 'when change column (add collation)' do | ||
let(:actual_dsl) { | ||
<<-RUBY | ||
create_table "employee_clubs", force: true do |t| | ||
t.integer "emp_no", null: false | ||
t.integer "club_id", null: false, unsigned: true | ||
t.string "string", null: false | ||
t.text "text", null: false | ||
end | ||
RUBY | ||
} | ||
|
||
let(:expected_dsl) { | ||
<<-RUBY | ||
create_table "employee_clubs", force: true do |t| | ||
t.integer "emp_no", null: false | ||
t.integer "club_id", null: false, unsigned: true | ||
t.string "string", null: false, collation: "ascii_bin" | ||
t.text "text", null: false, collation: "utf8mb4_bin" | ||
end | ||
RUBY | ||
} | ||
|
||
before { subject.diff(actual_dsl).migrate } | ||
subject { client } | ||
|
||
it { | ||
delta = subject.diff(expected_dsl) | ||
expect(delta.differ?).to be_truthy | ||
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip | ||
delta.migrate | ||
expect(subject.dump).to eq expected_dsl.strip_heredoc.strip | ||
} | ||
end | ||
|
||
context 'when change column (delete collation)' do | ||
let(:actual_dsl) { | ||
<<-RUBY | ||
create_table "employee_clubs", force: true do |t| | ||
t.integer "emp_no", null: false | ||
t.integer "club_id", null: false, unsigned: true | ||
t.string "string", null: false, collation: "ascii_bin" | ||
t.text "text", null: false, collation: "utf8mb4_bin" | ||
end | ||
RUBY | ||
} | ||
|
||
let(:expected_dsl) { | ||
<<-RUBY | ||
create_table "employee_clubs", force: true do |t| | ||
t.integer "emp_no", null: false | ||
t.integer "club_id", null: false, unsigned: true | ||
t.string "string", null: false | ||
t.text "text", null: false | ||
end | ||
RUBY | ||
} | ||
|
||
before { subject.diff(actual_dsl).migrate } | ||
subject { client } | ||
|
||
it { | ||
delta = subject.diff(expected_dsl) | ||
expect(delta.differ?).to be_truthy | ||
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip | ||
delta.migrate | ||
expect(subject.dump).to eq expected_dsl.strip_heredoc.strip | ||
} | ||
end | ||
|
||
context 'when change column (change collation)' do | ||
let(:actual_dsl) { | ||
<<-RUBY | ||
create_table "employee_clubs", force: true do |t| | ||
t.integer "emp_no", null: false | ||
t.integer "club_id", null: false, unsigned: true | ||
t.string "string", null: false, collation: "ascii_bin" | ||
t.text "text", null: false, collation: "utf8mb4_bin" | ||
end | ||
RUBY | ||
} | ||
|
||
let(:expected_dsl) { | ||
<<-RUBY | ||
create_table "employee_clubs", force: true do |t| | ||
t.integer "emp_no", null: false | ||
t.integer "club_id", null: false, unsigned: true | ||
t.string "string", null: false, collation: "utf8mb4_bin" | ||
t.text "text", null: false, collation: "ascii_bin" | ||
end | ||
RUBY | ||
} | ||
|
||
before { subject.diff(actual_dsl).migrate } | ||
subject { client } | ||
|
||
it { | ||
delta = subject.diff(expected_dsl) | ||
expect(delta.differ?).to be_truthy | ||
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip | ||
delta.migrate | ||
expect(subject.dump).to eq expected_dsl.strip_heredoc.strip | ||
} | ||
end | ||
|
||
context 'when change column (no change collation)' do | ||
let(:actual_dsl) { | ||
<<-RUBY | ||
create_table "employee_clubs", force: true do |t| | ||
t.integer "emp_no", null: false | ||
t.integer "club_id", null: false, unsigned: true | ||
t.string "string", null: false, collation: "ascii_bin" | ||
t.text "text", null: false, collation: "utf8mb4_bin" | ||
end | ||
RUBY | ||
} | ||
|
||
before { subject.diff(actual_dsl).migrate } | ||
subject { client } | ||
|
||
it { | ||
delta = subject.diff(actual_dsl) | ||
expect(delta.differ?).to be_falsey | ||
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip | ||
delta.migrate | ||
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip | ||
} | ||
end | ||
end | ||
end |
Oops, something went wrong.