mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Added :force option to create_table that'll try to drop the table if it already exists before creating
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2473 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Added :force option to create_table that'll try to drop the table if it already exists before creating
|
||||
|
||||
* Fix transactions so that calling return while inside a transaction will not leave an open transaction on the connection. [Nicholas Seckar]
|
||||
|
||||
* Use foreign_key inflection uniformly. #2156 [Blair Zajac <blair@orcaware.com>]
|
||||
|
||||
@@ -79,6 +79,11 @@ module ActiveRecord
|
||||
table_definition.primary_key(options[:primary_key] || "id") unless options[:id] == false
|
||||
|
||||
yield table_definition
|
||||
|
||||
if options[:force]
|
||||
drop_table(name) rescue nil
|
||||
end
|
||||
|
||||
create_sql = "CREATE#{' TEMPORARY' if options[:temporary]} TABLE "
|
||||
create_sql << "#{name} ("
|
||||
create_sql << table_definition.to_sql
|
||||
|
||||
@@ -53,6 +53,7 @@ HEADER
|
||||
|
||||
stream.print " create_table #{table.inspect}"
|
||||
stream.print ", :id => false" if !columns.detect { |c| c.name == "id" }
|
||||
stream.print ", :force => true"
|
||||
stream.puts " do |t|"
|
||||
|
||||
columns.each do |column|
|
||||
|
||||
Reference in New Issue
Block a user