Method: ActiveRecord::ConnectionAdapters::SchemaStatements#data_source_exists?

Defined in:
activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb

#data_source_exists?(name) ⇒ Boolean

Checks to see if the data source name exists on the database.

data_source_exists?(:ebooks)

Returns:

  • (Boolean)


45
46
47
48
49
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb', line 45

def data_source_exists?(name)
  query_values(data_source_sql(name), "SCHEMA").any? if name.present?
rescue NotImplementedError
  data_sources.include?(name.to_s)
end