diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-02-23 14:00:02 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-02-23 15:23:28 +0100 |
commit | 8f6fa345e5c865acefa063c3e2cd62553fa9f2eb (patch) | |
tree | 6eeef63a41866e2571ccf4f5157d2abadd5e4e50 /activerecord/test/cases/adapters/sqlite3 | |
parent | 0c1558d32fe7f3198ef598ce552ea89a04ab7793 (diff) | |
download | rails-8f6fa345e5c865acefa063c3e2cd62553fa9f2eb.tar.gz rails-8f6fa345e5c865acefa063c3e2cd62553fa9f2eb.tar.bz2 rails-8f6fa345e5c865acefa063c3e2cd62553fa9f2eb.zip |
Sqlite preserves primary keys when copying/altering tables.
Backport #2312.
Fixes #9367.
I also added a test-case to make sure that renaming or removing
a column preserves the primary key.
Diffstat (limited to 'activerecord/test/cases/adapters/sqlite3')
-rw-r--r-- | activerecord/test/cases/adapters/sqlite3/copy_table_test.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/sqlite3/copy_table_test.rb b/activerecord/test/cases/adapters/sqlite3/copy_table_test.rb index 575b4806c1..74288a98d1 100644 --- a/activerecord/test/cases/adapters/sqlite3/copy_table_test.rb +++ b/activerecord/test/cases/adapters/sqlite3/copy_table_test.rb @@ -57,6 +57,14 @@ class CopyTableTest < ActiveRecord::TestCase end end + def test_copy_table_with_unconventional_primary_key + test_copy_table('owners', 'owners_unconventional') do |from, to, options| + original_pk = @connection.primary_key('owners') + copied_pk = @connection.primary_key('owners_unconventional') + assert_equal original_pk, copied_pk + end + end + protected def copy_table(from, to, options = {}) @connection.copy_table(from, to, {:temporary => true}.merge(options)) |