lhm 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,19 +1,23 @@
1
- # 1.0.2 (Febuary 17, 2012)
1
+ # 1.0.3 (February 23, 2012)
2
+
3
+ * Improve change_column
4
+
5
+ # 1.0.2 (February 17, 2012)
2
6
 
3
7
  * closes https://github.com/soundcloud/large-hadron-migrator/issues/11
4
8
  this critical bug could cause data loss. table parser was replaced with
5
9
  an implementation that reads directly from information_schema.
6
10
 
7
- # 1.0.1 (Febuary 09, 2012)
11
+ # 1.0.1 (February 09, 2012)
8
12
 
9
13
  * released to rubygems
10
14
 
11
- # 1.0.0 (Febuary 09, 2012)
15
+ # 1.0.0 (February 09, 2012)
12
16
 
13
17
  * added change_column
14
18
  * final 1.0 release
15
19
 
16
- # 1.0.0.rc8 (Febuary 09, 2012)
20
+ # 1.0.0.rc8 (February 09, 2012)
17
21
 
18
22
  * removed spec binaries from gem bins
19
23
 
@@ -66,8 +66,7 @@ module Lhm
66
66
  # @param [String] name Name of the column to change
67
67
  # @param [String] definition Valid SQL column definition
68
68
  def change_column(name, definition)
69
- remove_column(name)
70
- add_column(name, definition)
69
+ ddl("alter table `%s` modify column `%s` %s" % [@name, name, definition])
71
70
  end
72
71
 
73
72
  # Remove a column from a table
@@ -2,5 +2,5 @@
2
2
  # Schmidt
3
3
 
4
4
  module Lhm
5
- VERSION = "1.0.2"
5
+ VERSION = "1.0.3"
6
6
  end
@@ -0,0 +1,4 @@
1
+ CREATE TABLE `small_table` (
2
+ `id` INT(11),
3
+ PRIMARY KEY (`id`)
4
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
@@ -119,6 +119,22 @@ describe Lhm do
119
119
  end
120
120
  end
121
121
 
122
+ it "should change the last column in a table" do
123
+ table_create(:small_table)
124
+
125
+ Lhm.change_table(:small_table) do |t|
126
+ t.change_column(:id, "int(5)")
127
+ end
128
+
129
+ slave do
130
+ table_read(:small_table).columns["id"].must_equal({
131
+ :type => "int(5)",
132
+ :is_nullable => "NO",
133
+ :column_default => "0"
134
+ })
135
+ end
136
+ end
137
+
122
138
  describe "parallel" do
123
139
  it "should perserve inserts during migration" do
124
140
  50.times { |n| execute("insert into users set reference = '#{ n }'") }
@@ -66,11 +66,10 @@ describe Lhm::Migrator do
66
66
  end
67
67
 
68
68
  it "should change a column" do
69
- @creator.change_column("logins", "INT(255)")
69
+ @creator.change_column("logins", "INT(11)")
70
70
 
71
71
  @creator.statements.must_equal([
72
- "alter table `lhmn_alt` drop `logins`",
73
- "alter table `lhmn_alt` add column `logins` INT(255)"
72
+ "alter table `lhmn_alt` modify column `logins` INT(11)"
74
73
  ])
75
74
  end
76
75
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: lhm
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.2
5
+ version: 1.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - SoundCloud
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2012-02-17 00:00:00 Z
16
+ date: 2012-02-22 00:00:00 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: mysql
@@ -98,6 +98,7 @@ files:
98
98
  - spec/bootstrap.rb
99
99
  - spec/fixtures/destination.ddl
100
100
  - spec/fixtures/origin.ddl
101
+ - spec/fixtures/small_table.ddl
101
102
  - spec/fixtures/users.ddl
102
103
  - spec/integration/chunker_spec.rb
103
104
  - spec/integration/entangler_spec.rb
@@ -146,6 +147,7 @@ test_files:
146
147
  - spec/bootstrap.rb
147
148
  - spec/fixtures/destination.ddl
148
149
  - spec/fixtures/origin.ddl
150
+ - spec/fixtures/small_table.ddl
149
151
  - spec/fixtures/users.ddl
150
152
  - spec/integration/chunker_spec.rb
151
153
  - spec/integration/entangler_spec.rb