Permalink
Browse files

added migration rename_column rename_table support

  • Loading branch information...
brantwedel committed Jun 1, 2014
1 parent 157f7dc commit 2a22e1b3ff20a5b5ba33bda2ab25dbf757cee9ab
Showing with 21 additions and 1 deletion.
  1. +20 −0 lib/yaddl.rb
  2. +1 −1 lib/yaddl/version.rb
View
@@ -125,6 +125,26 @@ def schema_diff
schema[attr_table] ||= {}
schema[attr_table].delete(attr_name)
end
if line =~ /^\s*rename_column(\s+|\().*$/
#add_column(table_name, column_name, type, options)
#change_column(table_name, column_name, type, options)
attr_table= line.sub(/^\s*[a-z_]+(\s+|\()\:([a-z_]+).*,.*\:([a-z_]+).*,.*\:([a-z_]+).*$/,'\2').strip
attr_name = line.sub(/^\s*[a-z_]+(\s+|\()\:([a-z_]+).*,.*\:([a-z_]+).*,.*\:([a-z_]+).*$/,'\3').strip
attr_rename = line.sub(/^\s*[a-z_]+(\s+|\()\:([a-z_]+).*,.*\:([a-z_]+).*,.*\:([a-z_]+).*$/,'\4').strip
schema[attr_table] ||= {}
attr_changed = !!schema[attr_table][attr_name]
schema[attr_table][attr_name] ||= {}
schema[attr_table][attr_rename] = schema[attr_table][attr_name]
schema[attr_table].delete(attr_name)
end
if line =~ /^\s*rename_table(\s+|\().*$/
attr_table= line.sub(/^\s*[a-z_]+(\s+|\()\:([a-z_]+).*,.*\:([a-z_]+).*$/,'\2').strip
attr_rename = line.sub(/^\s*[a-z_]+(\s+|\()\:([a-z_]+).*,.*\:([a-z_]+).*$/,'\3').strip
schema[attr_table] ||= {}
schema[attr_rename] = schema[attr_table]
schema[attr_table].delete(attr_name)
end
if line =~ /^\s*(add_column|change_column)(\s+|\().*$/
#add_column(table_name, column_name, type, options)
#change_column(table_name, column_name, type, options)
View
@@ -1,3 +1,3 @@
module Yaddl
VERSION = "0.1.5"
VERSION = "0.1.6"
end

0 comments on commit 2a22e1b

Please sign in to comment.