instance method
table_exists?
Ruby on Rails 8.1.2
Since v2.2.3Signature
table_exists?(table_name)
Checks to see if the table table_name exists on the database.
table_exists?(:developers)
Parameters
-
table_namereq
Source
# 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
Defined in activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb line 60
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::ConnectionAdapters::SchemaStatements