Fixed that altering join tables in migrations would fail w/ sqlite3 #7453 [TimoMihaljov/brandon]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7484 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
2fba012c01
commit
79202b37dc
|
@ -1,5 +1,7 @@
|
||||||
*SVN*
|
*SVN*
|
||||||
|
|
||||||
|
* Fixed that altering join tables in migrations would fail w/ sqlite3 #7453 [TimoMihaljov/brandon]
|
||||||
|
|
||||||
* Fix association writer with :dependent => :nullify. #7314 [Jonathan Viney]
|
* Fix association writer with :dependent => :nullify. #7314 [Jonathan Viney]
|
||||||
|
|
||||||
* OpenBase: update for new lib and latest Rails. Support migrations. #8748 [dcsesq]
|
* OpenBase: update for new lib and latest Rails. Support migrations. #8748 [dcsesq]
|
||||||
|
|
|
@ -285,6 +285,7 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_table(from, to, options = {}) #:nodoc:
|
def copy_table(from, to, options = {}) #:nodoc:
|
||||||
|
options = options.merge(:id => !columns(from).detect{|c| c.name == 'id'}.nil?)
|
||||||
create_table(to, options) do |@definition|
|
create_table(to, options) do |@definition|
|
||||||
columns(from).each do |column|
|
columns(from).each do |column|
|
||||||
column_name = options[:rename] ?
|
column_name = options[:rename] ?
|
||||||
|
@ -296,7 +297,7 @@ module ActiveRecord
|
||||||
:limit => column.limit, :default => column.default,
|
:limit => column.limit, :default => column.default,
|
||||||
:null => column.null)
|
:null => column.null)
|
||||||
end
|
end
|
||||||
@definition.primary_key(primary_key(from))
|
@definition.primary_key(primary_key(from)) if primary_key(from)
|
||||||
yield @definition if block_given?
|
yield @definition if block_given?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,10 @@ class CopyTableTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_copy_table_without_primary_key
|
||||||
|
test_copy_table('developers_projects', 'programmers_projects')
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
def copy_table(from, to, options = {})
|
def copy_table(from, to, options = {})
|
||||||
@connection.copy_table(from, to, {:temporary => true}.merge(options))
|
@connection.copy_table(from, to, {:temporary => true}.merge(options))
|
||||||
|
|
Loading…
Reference in New Issue