Ticket #10855: drop_table_if_exists_with_test.diff
| File drop_table_if_exists_with_test.diff, 1.7 kB (added by kampers, 5 months ago) |
|---|
-
activerecord/test/cases/migration_test.rb
old new 181 181 Person.connection.drop_table :testings rescue nil 182 182 end 183 183 184 # PostgreSQL returns an error when dropping a table that doesn't exist, 185 # unless you use <tt>IF EXISTS</tt>. <tt>:force => true</tt> uses this syntax. 186 if current_adapter?(:PostgreSQLAdapter) 187 def test_drop_table_force 188 assert_nothing_raised do 189 Person.connection.drop_table :does_not_exist, :force => true 190 end 191 end 192 end 193 184 194 # SQL Server, Sybase, and SQLite3 will not allow you to add a NOT NULL 185 195 # column to a table without a default value. 186 196 unless current_adapter?(:SQLServerAdapter, :SybaseAdapter, :SQLiteAdapter) -
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
old new 587 587 execute "ALTER TABLE #{name} RENAME TO #{new_name}" 588 588 end 589 589 590 # Drops a table from the database. 591 def drop_table(table_name, options = {}) 592 args = options[:force] ? " IF EXISTS" : "" 593 execute "DROP TABLE#{args} #{quote_table_name(table_name)}" 594 end 595 590 596 # Adds a new column to the named table. 591 597 # See TableDefinition#column for details of the options you can use. 592 598 def add_column(table_name, column_name, type, options = {})