ridgepole 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f20d24b4955d4b21970f0795d9202541c64387b
4
- data.tar.gz: ca0f973959d8c8a4580282240938ff40b0c8f064
3
+ metadata.gz: 763e47fb7ab7afd94ee8e5533bce0b33b9e40f30
4
+ data.tar.gz: a576e85765eecba93d42c4502dc84bfaee29807e
5
5
  SHA512:
6
- metadata.gz: a1956f2233beaf59f6d664fba626b79faa3594ef1fbc565e9f3ecd33c538a5801976bca703f8c5c8c50c94894e07073269a1e477ba1aaf084d0e0a90aeac2edd
7
- data.tar.gz: bfbd7ec8f1edd90ff24ce5f3c8cee7860b60a262f020c2b98ee1dfc4eba6bb98743fbd8397b73706b087d11dbcfdfe964ed3bced3772bfb20b0ba0d95f73d4fc
6
+ metadata.gz: c1fac2ed18393ceddc641861b744ab3d081daa790c26f7de85e81948118bd7aec7a613d121d420de1655c81887994a63724ee5614c00dfc54ec2c7835ed87728
7
+ data.tar.gz: b1f2d4ad9dafc8ea3e0febb7f3f5914156230e0034b0e90a431b1eabb52d11a61705c0b82824e45eea76f694259b0bf8863f2f23530e428713807943b2c94da5
data/README.md CHANGED
@@ -30,6 +30,7 @@ Usage: ridgepole [options]
30
30
  -m, --merge
31
31
  -f, --file FILE
32
32
  --dry-run
33
+ --table-options
33
34
  -e, --export
34
35
  --split
35
36
  --split-with-dir
data/bin/ridgepole CHANGED
@@ -32,11 +32,11 @@ set_mode = proc do |m|
32
32
  end
33
33
 
34
34
  def noop_migrate(delta)
35
- puts <<-EOS
36
- #{delta.script}
35
+ puts delta.script + "\n\n"
37
36
 
38
- #{delta.migrate(:noop => true).each_line.map {|i| "# #{i}"}.join}
39
- EOS
37
+ delta.migrate(:noop => true).each_line do |line|
38
+ puts line.strip.gsub(/([^\d])([(),])([^\d])/) { "#{$1}#{$2}\n#{$3}" }.each_line.map {|i| "# #{i.gsub(/^\s+/, '')}"}.join + "\n\n"
39
+ end
40
40
  end
41
41
 
42
42
  ARGV.options do |opt|
@@ -46,6 +46,7 @@ ARGV.options do |opt|
46
46
  opt.on('-m', '--merge') { set_mode[:apply]; options[:merge] = true }
47
47
  opt.on('-f', '--file FILE') {|v| file = v }
48
48
  opt.on('', '--dry-run') { options[:dry_run] = true }
49
+ opt.on('', '--table-options') {|v| options[:table_options] = v }
49
50
  opt.on('-e', '--export') { set_mode[:export] }
50
51
  opt.on('', '--split') {|v| split = true }
51
52
  opt.on('', '--split-with-dir') {|v| split = :with_dir }
@@ -115,6 +115,7 @@ class Ridgepole::Delta
115
115
 
116
116
  def append_create_table(table_name, attrs, buf)
117
117
  options = attrs[:options] || {}
118
+ options[:options] ||= @options[:table_options] if @options[:table_options]
118
119
  definition = attrs[:definition] || {}
119
120
  indices = attrs[:indices] || {}
120
121
 
@@ -1,3 +1,3 @@
1
1
  module Ridgepole
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -0,0 +1,29 @@
1
+ describe 'Ridgepole::Client#diff -> migrate' do
2
+ context 'when create table' do
3
+ let(:expected_dsl) {
4
+ <<-RUBY
5
+ create_table "employee_clubs", force: true do |t|
6
+ t.integer "emp_no", unsigned: true, null: false
7
+ t.integer "club_id", unsigned: true, null: false
8
+ end
9
+
10
+ add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
11
+ RUBY
12
+ }
13
+
14
+ subject { client(table_options: 'ENGINE=MyISAM CHARSET=utf8') }
15
+
16
+ it {
17
+ delta = subject.diff(expected_dsl)
18
+ expect(delta.differ?).to be_truthy
19
+
20
+ expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
21
+ create_table("employee_clubs", {:options=>"ENGINE=MyISAM CHARSET=utf8"}) do |t|
22
+ t.integer("emp_no", {:unsigned=>true, :null=>false})
23
+ t.integer("club_id", {:unsigned=>true, :null=>false})
24
+ end
25
+ add_index("employee_clubs", ["emp_no", "club_id"], {:name=>"idx_emp_no_club_id", :using=>:btree})
26
+ RUBY
27
+ }
28
+ end
29
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ridgepole
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-23 00:00:00.000000000 Z
11
+ date: 2014-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -134,6 +134,7 @@ files:
134
134
  - spec/migrate/migrate_change_table_option_spec.rb
135
135
  - spec/migrate/migrate_create_index_spec.rb
136
136
  - spec/migrate/migrate_create_table_spec.rb
137
+ - spec/migrate/migrate_create_table_with_options_spec.rb
137
138
  - spec/migrate/migrate_drop_column_and_index_2_spec.rb
138
139
  - spec/migrate/migrate_drop_column_and_index_spec.rb
139
140
  - spec/migrate/migrate_drop_column_spec.rb
@@ -194,6 +195,7 @@ test_files:
194
195
  - spec/migrate/migrate_change_table_option_spec.rb
195
196
  - spec/migrate/migrate_create_index_spec.rb
196
197
  - spec/migrate/migrate_create_table_spec.rb
198
+ - spec/migrate/migrate_create_table_with_options_spec.rb
197
199
  - spec/migrate/migrate_drop_column_and_index_2_spec.rb
198
200
  - spec/migrate/migrate_drop_column_and_index_spec.rb
199
201
  - spec/migrate/migrate_drop_column_spec.rb