Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #10855: drop_table_if_exists.diff

File drop_table_if_exists.diff, 0.6 kB (added by adamwiggins, 9 months ago)

Drop table if exists for postgresql adapter only.

  • a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb

    old new  
    585585        execute "ALTER TABLE #{name} RENAME TO #{new_name}" 
    586586      end 
    587587 
     588      # Drops a table from the database. 
     589      def drop_table(table_name, options = {}) 
     590        args = options[:force] ? " IF EXISTS" : "" 
     591        execute "DROP TABLE#{args} #{quote_table_name(table_name)}" 
     592      end 
     593 
    588594      # Adds a column to a table. 
    589595      def add_column(table_name, column_name, type, options = {}) 
    590596        default = options[:default]