sequel_migration_builder 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -17,12 +17,18 @@ module Sequel
17
17
  end.flatten
18
18
 
19
19
  new_column_names = new_table[:columns].map {|c| c.name }
20
- operations += (db_columns.keys - new_column_names).map {|name| DropColumn.new(db_columns[name]) }
20
+ dropped_columns = db_columns.keys - new_column_names
21
+
22
+ operations += dropped_columns.map do |name|
23
+ DropColumn.new(db_columns[name])
24
+ end
21
25
 
22
26
  db_indexes = db_table[:indexes] || {}
23
27
  new_indexes = new_table[:indexes] || {}
24
28
 
25
- operations += (db_indexes.keys - new_indexes.keys).map do |index_name|
29
+ operations += (db_indexes.keys - new_indexes.keys).reject do |index_name|
30
+ db_indexes[index_name][:columns].size == 1 && dropped_columns.include?(db_indexes[index_name][:columns].first)
31
+ end.map do |index_name|
26
32
  DropIndex.new(index_name,
27
33
  db_indexes[index_name][:columns],
28
34
  db_indexes[index_name][:unique])
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sequel_migration_builder}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Roland Swingler"]
12
- s.date = %q{2010-07-13}
12
+ s.date = %q{2010-08-09}
13
13
  s.description = %q{Build Sequel Migrations based on the differences between two schemas}
14
14
  s.email = %q{roland.swingler@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -113,6 +113,17 @@ describe "Sequel::Schema::AlterTableOperations.build" do
113
113
  ops.size.should == 1
114
114
  ops.first.should be_kind_of(Sequel::Schema::AlterTableOperations::ChangeColumn)
115
115
  end
116
+
117
+ it "should not output a drop index if the index's column is also removed" do
118
+ table_a = {:name => :example_table,
119
+ :indexes => {:foo_idx => {:columns => [:foo]}},
120
+ :columns => [build_column(:name => :foo, :column_type => :integer)]}
121
+ table_b = {:name => :example_table, :indexes => {}, :columns => []}
122
+ ops = Sequel::Schema::AlterTableOperations.build(table_a,table_b)
123
+
124
+ ops.size.should == 1
125
+ ops.first.should be_kind_of(Sequel::Schema::AlterTableOperations::DropColumn)
126
+ end
116
127
  end
117
128
 
118
129
  describe Sequel::Schema::AlterTableOperations::AddColumn do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 2
9
- version: 0.1.2
8
+ - 3
9
+ version: 0.1.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Roland Swingler
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-13 00:00:00 +01:00
17
+ date: 2010-08-09 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency