ridgepole 0.6.0.beta3 → 0.6.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f3f7ab0526aeeb91e3a59961689faac1fe121581
4
- data.tar.gz: 17600a9bd516754b1a07a71884a485130fdd2fa6
3
+ metadata.gz: bc1b762a10fbde926c1087d0908416e96c3c10ed
4
+ data.tar.gz: b0e1bce4be3f05dbfe958baae95f81c6b5f5bbc0
5
5
  SHA512:
6
- metadata.gz: afe473047299f94e4dfec5666fa178ce69c9582b7eb9e18e40efae6369d284e4471c935889d7f9c833fc1c50dfb84e001cce78a34fde16bbe63c3a76ac85ec9f
7
- data.tar.gz: 6601bd9271465052f305a0e4321ecb0cf90a870f267412f651341f082ab05011a836aa050ec18e21f1c00641ddbdd5bef695b58b203afdf9f02c49534b8ea9e0
6
+ metadata.gz: 8a39a465ca7cdbf447b68fc16a4bcc6a8c4adcbe49861244ebad89766ed298f7a5bd106a54dee5872de30c04f45e0e78a83a41fceab4e0415473fa2ca37fe6fd
7
+ data.tar.gz: ec19f3aee132852785a6c3198b36212c617e17d3c54c98c2286db13567edc3a12031419c0535c19e582800f4d48cff460c0faf6a221362879a6475bb63b0e089
data/README.md CHANGED
@@ -66,6 +66,7 @@ Usage: ridgepole [options]
66
66
  --default-float-limit LIMIT
67
67
  --default-string-limit LIMIT
68
68
  --default-text-limit LIMIT
69
+ --default-binary-limit LIMIT
69
70
  --pre-query QUERY
70
71
  --post-query QUERY
71
72
  -e, --export
data/bin/ridgepole CHANGED
@@ -13,6 +13,15 @@ $stderr.sync = true
13
13
  Version = Ridgepole::VERSION
14
14
  DEFAULT_FILENAME = 'Schemafile'
15
15
 
16
+ COLUMN_TYPES = {
17
+ :boolean => :bool,
18
+ :integer => :int,
19
+ :float => :float,
20
+ :string => :string,
21
+ :text => :text,
22
+ :binary => :binary,
23
+ }
24
+
16
25
  config = nil
17
26
  env = 'development'
18
27
  mode = nil
@@ -66,21 +75,13 @@ ARGV.options do |opt|
66
75
  raise "Cannot use `bulk-change` in `merge`" if options[:merge]
67
76
  options[:bulk_change] = true
68
77
  }
69
- opt.on('', "--default-bool-limit LIMIT", Integer) {|v|
70
- options[:default_boolean_limit] = v
71
- }
72
- opt.on('', "--default-int-limit LIMIT", Integer) {|v|
73
- options[:"default_integer_limit"] = v
74
- }
75
- opt.on('', "--default-float-limit LIMIT", Integer) {|v|
76
- options[:"default_float_limit"] = v
77
- }
78
- opt.on('', "--default-string-limit LIMIT", Integer) {|v|
79
- options[:"default_string_limit"] = v
80
- }
81
- opt.on('', "--default-text-limit LIMIT", Integer) {|v|
82
- options[:"default_text_limit"] = v
83
- }
78
+
79
+ COLUMN_TYPES.each do |column_type, column_type_alias|
80
+ opt.on('', "--default-#{column_type_alias}-limit LIMIT", Integer) {|v|
81
+ options[:"default_boolean_#{column_type}"] = v
82
+ }
83
+ end
84
+
84
85
  opt.on('', '--pre-query QUERY') {|v| options[:pre_query] = v }
85
86
  opt.on('', '--post-query QUERY') {|v| options[:post_query] = v }
86
87
  opt.on('-e', '--export') { set_mode[:export] }
@@ -6,6 +6,7 @@ class Ridgepole::DefaultsLimit
6
6
  :float => 24,
7
7
  :string => 255,
8
8
  :text => 65535,
9
+ :binary => 65535,
9
10
  }
10
11
  }
11
12
 
@@ -3,6 +3,10 @@ class ActiveRecord::ConnectionAdapters::TableDefinition
3
3
  alias primary_key_without_unsigned primary_key
4
4
 
5
5
  def primary_key(name, type = :primary_key, options = {})
6
- primary_key_without_unsigned(name, type, options.merge(primary_key: true).reverse_merge(unsigned: true))
6
+ if options.has_key?(:id)
7
+ primary_key_without_unsigned(name, type, options)
8
+ else
9
+ primary_key_without_unsigned(name, type, options.merge(primary_key: true).reverse_merge(unsigned: true))
10
+ end
7
11
  end
8
12
  end
@@ -1,3 +1,3 @@
1
1
  module Ridgepole
2
- VERSION = '0.6.0.beta3'
2
+ VERSION = '0.6.0.beta4'
3
3
  end
@@ -23,6 +23,7 @@ describe 'ridgepole' do
23
23
  --default-float-limit LIMIT
24
24
  --default-string-limit LIMIT
25
25
  --default-text-limit LIMIT
26
+ --default-binary-limit LIMIT
26
27
  --pre-query QUERY
27
28
  --post-query QUERY
28
29
  -e, --export
@@ -0,0 +1,129 @@
1
+ unless postgresql?
2
+ describe 'Ridgepole::Client#diff -> migrate' do
3
+ context 'when change column (binary: blob -> varbinary)' do
4
+ let(:actual_dsl) {
5
+ <<-RUBY
6
+ create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
7
+ t.date "birth_date", null: false
8
+ t.string "first_name", limit: 14, null: false
9
+ t.string "last_name", limit: 16, null: false
10
+ t.string "gender", limit: 1, null: false
11
+ t.date "hire_date", null: false
12
+ t.datetime "created_at", null: false
13
+ t.datetime "updated_at", null: false
14
+ t.binary "registered_name", limit: 65535
15
+ end
16
+ RUBY
17
+ }
18
+
19
+ let(:expected_dsl) {
20
+ <<-RUBY
21
+ create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
22
+ t.date "birth_date", null: false
23
+ t.string "first_name", limit: 14, null: false
24
+ t.string "last_name", limit: 16, null: false
25
+ t.string "gender", limit: 1, null: false
26
+ t.date "hire_date", null: false
27
+ t.datetime "created_at", null: false
28
+ t.datetime "updated_at", null: false
29
+ t.binary "registered_name", limit: 255
30
+ end
31
+ RUBY
32
+ }
33
+
34
+ before { subject.diff(actual_dsl).migrate }
35
+ subject { client }
36
+
37
+ it {
38
+ delta = subject.diff(expected_dsl)
39
+ expect(delta.differ?).to be_truthy
40
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
41
+ delta.migrate
42
+ expect(subject.dump).to eq expected_dsl.strip_heredoc.strip.gsub(/(\s*,\s*unsigned: false)?\s*,\s*null: true/, '')
43
+ }
44
+ end
45
+
46
+ context 'when change column (binary: varbinary -> blob)' do
47
+ let(:actual_dsl) {
48
+ <<-RUBY
49
+ create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
50
+ t.date "birth_date", null: false
51
+ t.string "first_name", limit: 14, null: false
52
+ t.string "last_name", limit: 16, null: false
53
+ t.string "gender", limit: 1, null: false
54
+ t.date "hire_date", null: false
55
+ t.datetime "created_at", null: false
56
+ t.datetime "updated_at", null: false
57
+ t.binary "registered_name", limit: 255
58
+ end
59
+ RUBY
60
+ }
61
+
62
+ let(:expected_dsl) {
63
+ <<-RUBY
64
+ create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
65
+ t.date "birth_date", null: false
66
+ t.string "first_name", limit: 14, null: false
67
+ t.string "last_name", limit: 16, null: false
68
+ t.string "gender", limit: 1, null: false
69
+ t.date "hire_date", null: false
70
+ t.datetime "created_at", null: false
71
+ t.datetime "updated_at", null: false
72
+ t.binary "registered_name", limit: 65535
73
+ end
74
+ RUBY
75
+ }
76
+
77
+ before { subject.diff(actual_dsl).migrate }
78
+ subject { client }
79
+
80
+ it {
81
+ delta = subject.diff(expected_dsl)
82
+ expect(delta.differ?).to be_truthy
83
+ expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
84
+ delta.migrate
85
+ expect(subject.dump).to eq expected_dsl.strip_heredoc.strip.gsub(/(\s*,\s*unsigned: false)?\s*,\s*null: true/, '')
86
+ }
87
+ end
88
+
89
+ context 'when change column (binary without limit)' do
90
+ let(:actual_dsl) {
91
+ <<-RUBY
92
+ create_table "employees", primary_key: "emp_no", force: :cascade do |t|
93
+ t.date "birth_date", null: false
94
+ t.string "first_name", limit: 14, null: false
95
+ t.string "last_name", limit: 16, null: false
96
+ t.string "gender", limit: 1, null: false
97
+ t.date "hire_date", null: false
98
+ t.datetime "created_at", null: false
99
+ t.datetime "updated_at", null: false
100
+ t.binary "registered_name", limit: 65535
101
+ end
102
+ RUBY
103
+ }
104
+
105
+ let(:expected_dsl) {
106
+ <<-RUBY
107
+ create_table "employees", primary_key: "emp_no", force: :cascade do |t|
108
+ t.date "birth_date", null: false
109
+ t.string "first_name", limit: 14, null: false
110
+ t.string "last_name", limit: 16, null: false
111
+ t.string "gender", limit: 1, null: false
112
+ t.date "hire_date", null: false
113
+ t.datetime "created_at", null: false
114
+ t.datetime "updated_at", null: false
115
+ t.binary "registered_name"
116
+ end
117
+ RUBY
118
+ }
119
+
120
+ before { subject.diff(actual_dsl).migrate }
121
+ subject { client }
122
+
123
+ it {
124
+ delta = subject.diff(expected_dsl)
125
+ expect(delta.differ?).to be_falsey
126
+ }
127
+ end
128
+ end
129
+ 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.6.0.beta3
4
+ version: 0.6.0.beta4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-12 00:00:00.000000000 Z
11
+ date: 2015-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -173,6 +173,7 @@ files:
173
173
  - spec/mysql/migrate/migrate_change_column2_spec.rb
174
174
  - spec/mysql/migrate/migrate_change_column3_spec.rb
175
175
  - spec/mysql/migrate/migrate_change_column4_spec.rb
176
+ - spec/mysql/migrate/migrate_change_column5_spec.rb
176
177
  - spec/mysql/migrate/migrate_change_column_float_spec.rb
177
178
  - spec/mysql/migrate/migrate_change_column_spec.rb
178
179
  - spec/mysql/migrate/migrate_change_index2_spec.rb
@@ -271,6 +272,7 @@ test_files:
271
272
  - spec/mysql/migrate/migrate_change_column2_spec.rb
272
273
  - spec/mysql/migrate/migrate_change_column3_spec.rb
273
274
  - spec/mysql/migrate/migrate_change_column4_spec.rb
275
+ - spec/mysql/migrate/migrate_change_column5_spec.rb
274
276
  - spec/mysql/migrate/migrate_change_column_float_spec.rb
275
277
  - spec/mysql/migrate/migrate_change_column_spec.rb
276
278
  - spec/mysql/migrate/migrate_change_index2_spec.rb