Method: ActiveRecord::ConnectionAdapters::SchemaStatements#table_exists?
- Defined in:
- activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
#table_exists?(table_name) ⇒ Boolean
Checks to see if the table table_name
exists on the database.
table_exists?(:developers)
60 61 62 63 64 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb', line 60 def table_exists?(table_name) query_values(data_source_sql(table_name, type: "BASE TABLE"), "SCHEMA").any? if table_name.present? rescue NotImplementedError tables.include?(table_name.to_s) end |