column_exists?(table_name, column_name, type = nil, options = {})
Instance Public methods
Checks to see if a column exists in a given table.
1 2 3 4 5 6 7 8 9 10 11 | # Check a column exists column_exists?( :suppliers , :name ) # Check a column exists of a particular type column_exists?( :suppliers , :name , :string ) # Check a column exists with a specific definition column_exists?( :suppliers , :name , :string , limit: 100 ) column_exists?( :suppliers , :name , :string , default: 'default' ) column_exists?( :suppliers , :name , :string , null: false ) column_exists?( :suppliers , :tax , :decimal , precision: 8 , scale: 2 ) |
Please login to continue.