Skip to content

Commit

Permalink
Replace if exists with table_exists? and drop table statement wit…
Browse files Browse the repository at this point in the history
…h `drop_table`

since 'drop table if exists' statement does not always work with some databases such as Oracle.
also Oracle drop table statement will not drop sequence objects.
  • Loading branch information
yahonda committed Jan 21, 2015
1 parent be9b680 commit ed3c38c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class ReferencesForeignKeyTest < ActiveRecord::TestCase
end

teardown do
@connection.execute("drop table if exists testings")
@connection.execute("drop table if exists testing_parents")
@connection.drop_table("testings") if @connection.table_exists? "testings"
@connection.drop_table("testing_parents") if @connection.table_exists? "testing_parents"
end

test "foreign keys can be created with the table" do
Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/cases/primary_keys_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class Barcode < ActiveRecord::Base
end

teardown do
@connection.execute("DROP TABLE IF EXISTS barcodes")
@connection.drop_table(:barcodes) if @connection.table_exists? :barcodes
end

def test_any_type_primary_key
Expand Down

0 comments on commit ed3c38c

Please sign in to comment.