method
change_column_null
Ruby on Rails latest stable (v7.1.3.2)
-
0 notes -
Class: ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
change_column_null(table_name, column_name, null, default = nil)
public
Hide source
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 1042 def change_column_null(table_name, column_name, null, default = nil) clear_cache! unless null || default.nil? execute("UPDATE #{quote_table_name(table_name)} SET #{quote_column_name(column_name)}=#{quote(default)} WHERE #{quote_column_name(column_name)} IS NULL") end execute("ALTER TABLE #{quote_table_name(table_name)} ALTER #{quote_column_name(column_name)} #{null ? 'DROP' : 'SET'} NOT NULL") end