public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
SQLite: rename_column raises if the column doesn't exist.

[#622 state:resolved]
Tarmo Tänav (author)
Mon Jul 14 19:24:24 -0700 2008
jeremy (committer)
Mon Jul 14 22:58:22 -0700 2008
commit  c1531ae00dbd3ac804bce02733e050ec43400607
tree    01334d4f81640eccbe96febe7bda96884b5f95d4
parent  8c91b767c0f36e9d767eb230ec42b111e57d90da
...
260
261
262
 
 
 
263
264
265
...
260
261
262
263
264
265
266
267
268
0
@@ -260,6 +260,9 @@ module ActiveRecord
0
       end
0
 
0
       def rename_column(table_name, column_name, new_column_name) #:nodoc:
0
+        unless columns(table_name).detect{|c| c.name == column_name.to_s }
0
+          raise ActiveRecord::ActiveRecordError, "Missing column #{table_name}.#{column_name}"
0
+        end
0
         alter_table(table_name, :rename => {column_name.to_s => new_column_name.to_s})
0
       end
0
 

Comments