En Rails 5, la API se hizo explícita con respecto a tablas / vistas , colectivamente fuentes de datos .
# Tables and views
ActiveRecord::Base.connection.data_sources
ActiveRecord::Base.connection.data_source_exists? 'kittens'
# Tables
ActiveRecord::Base.connection.tables
ActiveRecord::Base.connection.table_exists? 'kittens'
# Views
ActiveRecord::Base.connection.views
ActiveRecord::Base.connection.view_exists? 'kittens'
En Rails 2, 3 y 4, la API trata sobre tablas .
# Listing of all tables and views
ActiveRecord::Base.connection.tables
# Checks for existence of kittens table/view (Kitten model)
ActiveRecord::Base.connection.table_exists? 'kittens'
Obtener el estado de las migraciones:
# Tells you all migrations run
ActiveRecord::Migrator.get_all_versions
# Tells you the current schema version
ActiveRecord::Migrator.current_version
Si necesita más API para migraciones o metadatos, consulte: