sequel_migration_builder 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/{spec/spec.opts → .rspec} +0 -0
- data/VERSION +1 -1
- data/lib/sequel/schema/alter_table_operations.rb +17 -4
- data/sequel_migration_builder.gemspec +4 -4
- data/spec/alter_table_operations_spec.rb +38 -0
- data/spec/migration_builder_spec.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Njg3ZTNiMGUxODIzYTVhZjUxM2I1MTA1NmY1MzY1NzY4MWMyZjY3NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Y2QxNmE3M2Y4OTk5MmFmNTkxN2UyNWM3NjA4Y2I1MWVmMTM5MmI0Yg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDYwODNkZDlmOGQ4OTYwM2YyNmU3OGE5ODdhMDM0ZDVjYTA5ZTY5NzQ4ZjI5
|
10
|
+
ZDY3NmU0YTA1MThhNDlhNTVhYmVjYzI3ZWVhNzU5NDhhYWExNzA3ZGM5OGIy
|
11
|
+
NDhhODQyYzJiMWYzMWQ3NzFmOTBhN2Q3MDJmMDZmMjBhMDA2Zjk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjFmZDgxZDZmNDJiNGJkYjJkN2Y3MjMyZjFkYWRkM2M4MDZhMWE5NGRlZDc2
|
14
|
+
Mzc0MjdlYjZmOTYyYjY3ZWRlMDZhY2JmODgzOGFlNDM0MDFjNTBiODFkYzdj
|
15
|
+
M2IyMDYxMTU2ZDkxNTJhNDdlM2M1NzIzODVkYWE1NDc0NTNkNmM=
|
data/{spec/spec.opts → .rspec}
RENAMED
File without changes
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.3
|
@@ -52,16 +52,29 @@ module Sequel
|
|
52
52
|
diffs = db_column.diff(new_column)
|
53
53
|
|
54
54
|
if @immutable_columns && !diffs.empty?
|
55
|
-
result <<
|
56
|
-
|
55
|
+
result << new_column.drop_statement
|
56
|
+
|
57
|
+
statement = new_column.add_statement
|
58
|
+
result << (statement.include?(":default") ? statement : statement + ", :default => #{assumed_default(new_column)}")
|
59
|
+
result
|
57
60
|
else
|
58
61
|
result << :change_type_statement if [:elements, :column_type, :size, :unsigned].any? {|sym| diffs.include?(sym) }
|
59
62
|
# only need to explicitly set the default if we're not changing the column type.
|
60
63
|
result << :change_default_statement if diffs.include?(:default) && result.empty?
|
61
64
|
result << :change_null_statement if diffs.include?(:null)
|
65
|
+
|
66
|
+
result.map {|statement| new_column.__send__(statement) }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def assumed_default(column)
|
71
|
+
if column.numeric?
|
72
|
+
0
|
73
|
+
elsif column.column_type == :varchar || column.column_type == :char
|
74
|
+
''
|
75
|
+
elsif column.column_type == :boolean
|
76
|
+
false
|
62
77
|
end
|
63
|
-
|
64
|
-
result.map {|statement| new_column.__send__(statement) }
|
65
78
|
end
|
66
79
|
end
|
67
80
|
end
|
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: sequel_migration_builder 0.4.
|
5
|
+
# stub: sequel_migration_builder 0.4.3 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "sequel_migration_builder"
|
9
|
-
s.version = "0.4.
|
9
|
+
s.version = "0.4.3"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Roland Swingler"]
|
14
|
-
s.date = "2014-09-
|
14
|
+
s.date = "2014-09-08"
|
15
15
|
s.description = "Build Sequel Migrations based on the differences between two schemas"
|
16
16
|
s.email = "roland.swingler@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
]
|
21
21
|
s.files = [
|
22
22
|
".document",
|
23
|
+
".rspec",
|
23
24
|
"CHANGELOG",
|
24
25
|
"LICENSE",
|
25
26
|
"README.rdoc",
|
@@ -36,7 +37,6 @@ Gem::Specification.new do |s|
|
|
36
37
|
"spec/db_index_spec.rb",
|
37
38
|
"spec/db_schema_parser_spec.rb",
|
38
39
|
"spec/migration_builder_spec.rb",
|
39
|
-
"spec/spec.opts",
|
40
40
|
"spec/spec_helper.rb"
|
41
41
|
]
|
42
42
|
s.homepage = "http://github.com/knaveofdiamonds/sequel_migration_builder"
|
@@ -80,6 +80,7 @@ describe "Sequel::Schema::AlterTableOperations#build_column_operations" do
|
|
80
80
|
|
81
81
|
expect(ops.first).to eql("set_column_type :foo, :enum, :default => nil, :elements => [\"A\", \"B\"]")
|
82
82
|
end
|
83
|
+
|
83
84
|
end
|
84
85
|
|
85
86
|
describe "Sequel::Schema::AlterTableOperations.build" do
|
@@ -145,4 +146,41 @@ describe "Sequel::Schema::AlterTableOperations.build" do
|
|
145
146
|
ops = Sequel::Schema::AlterTableOperations.build(table_a,table_b)
|
146
147
|
expect(ops).to eql([])
|
147
148
|
end
|
149
|
+
|
150
|
+
context "with immutable_columns set" do
|
151
|
+
subject {
|
152
|
+
Sequel::Schema::AlterTableOperations.new(:immutable_columns => true)
|
153
|
+
}
|
154
|
+
|
155
|
+
it "doesn't change columns that are not different" do
|
156
|
+
table_a = {:name => :example_table,
|
157
|
+
:columns => [build_column(:name => :foo, :column_type => :integer)]}
|
158
|
+
table_b = {:name => :example_table,
|
159
|
+
:columns => [build_column(:name => :foo, :column_type => :integer)]}
|
160
|
+
ops = subject.build(table_a,table_b)
|
161
|
+
|
162
|
+
expect(ops).to be_empty
|
163
|
+
end
|
164
|
+
|
165
|
+
it "drops and adds a column with immutable columns set" do
|
166
|
+
table_a = {:name => :example_table,
|
167
|
+
:columns => [build_column(:name => :foo, :column_type => :integer, :allow_null => true)]}
|
168
|
+
table_b = {:name => :example_table,
|
169
|
+
:columns => [build_column(:name => :foo, :column_type => :smallint, :allow_null => true)]}
|
170
|
+
ops = subject.build(table_a,table_b)
|
171
|
+
|
172
|
+
expect(ops.size).to eql(2)
|
173
|
+
expect(ops.first).to match(/drop_column :foo/)
|
174
|
+
expect(ops.last).to match(/add_column :foo/)
|
175
|
+
end
|
176
|
+
|
177
|
+
it "adds an assumed default to NOT NULL columns when changed" do
|
178
|
+
table_a = {:name => :example_table,
|
179
|
+
:columns => [build_column(:name => :foo, :column_type => :integer, :allow_null => false)]}
|
180
|
+
table_b = {:name => :example_table,
|
181
|
+
:columns => [build_column(:name => :foo, :column_type => :boolean, :allow_null => false)]}
|
182
|
+
ops = subject.build(table_a,table_b)
|
183
|
+
expect(ops.last).to match(/:default => false/)
|
184
|
+
end
|
185
|
+
end
|
148
186
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel_migration_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roland Swingler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -47,6 +47,7 @@ extra_rdoc_files:
|
|
47
47
|
- README.rdoc
|
48
48
|
files:
|
49
49
|
- .document
|
50
|
+
- .rspec
|
50
51
|
- CHANGELOG
|
51
52
|
- LICENSE
|
52
53
|
- README.rdoc
|
@@ -63,7 +64,6 @@ files:
|
|
63
64
|
- spec/db_index_spec.rb
|
64
65
|
- spec/db_schema_parser_spec.rb
|
65
66
|
- spec/migration_builder_spec.rb
|
66
|
-
- spec/spec.opts
|
67
67
|
- spec/spec_helper.rb
|
68
68
|
homepage: http://github.com/knaveofdiamonds/sequel_migration_builder
|
69
69
|
licenses: []
|