Method: Sequel::Database#table_exists?

Defined in:
lib/sequel/database.rb

#table_exists?(name) ⇒ Boolean

Returns true if a table with the given name exists. This requires a query to the database unless this database object already has the schema for the given table name.

Returns:

  • (Boolean)


431
432
433
434
435
436
437
438
439
440
441
442
# File 'lib/sequel/database.rb', line 431

def table_exists?(name)
  if @schemas && @schemas[name]
    true
  else
    begin 
      from(name).first
      true
    rescue
      false
    end
  end
end