Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

1.0.0

  • Loading branch information...
commit 7705c5a942197837748f2b5bcf6fb497148d9935 1 parent 72f4c6f
@purzelrakete purzelrakete authored
View
5 CHANGELOG.md
@@ -1,3 +1,8 @@
+# 1.0.0 (Febuary 09, 2012)
+
+* added change_column
+* final 1.0 release
+
# 1.0.0.rc8 (Febuary 09, 2012)
* removed spec binaries from gem bins
View
15 lib/lhm/migrator.rb
@@ -55,6 +55,21 @@ def add_column(name, definition)
ddl("alter table `%s` add column `%s` %s" % [@name, name, definition])
end
+ # Change an existing column to a new definition
+ #
+ # @example
+ #
+ # Lhm.change_table(:users) do |m|
+ # m.change_column(:comment, "VARCHAR(12) DEFAULT '0' NOT NULL")
+ # end
+ #
+ # @param [String] name Name of the column to change
+ # @param [String] definition Valid SQL column definition
+ def change_column(name, definition)
+ remove_column(name)
+ add_column(name, definition)
+ end
+
# Remove a column from a table
#
# @example
View
2  lib/lhm/version.rb
@@ -2,5 +2,5 @@
# Schmidt
module Lhm
- VERSION = "1.0.0.rc8"
+ VERSION = "1.0.0"
end
View
13 spec/integration/lhm_spec.rb
@@ -103,6 +103,19 @@
end
end
+ it "should change a column" do
+ Lhm.change_table(:users) do |t|
+ t.change_column(:comment, "varchar(20) DEFAULT 'none' NOT NULL")
+ end
+
+ slave do
+ table_read(:users).columns["comment"].must_equal({
+ :type => "varchar(20)",
+ :metadata => "NOT NULL DEFAULT 'none'"
+ })
+ end
+ end
+
describe "parallel" do
it "should perserve inserts during migration" do
50.times { |n| execute("insert into users set reference = '#{ n }'") }
View
9 spec/unit/migrator_spec.rb
@@ -64,6 +64,15 @@
"alter table `lhmn_alt` drop `logins`"
])
end
+
+ it "should change a column" do
+ @creator.change_column("logins", "INT(255)")
+
+ @creator.statements.must_equal([
+ "alter table `lhmn_alt` drop `logins`",
+ "alter table `lhmn_alt` add column `logins` INT(255)"
+ ])
+ end
end
describe "direct changes" do
Please sign in to comment.
Something went wrong with that request. Please try again.