Dalam Rails 5 API menjadi eksplisit mengenai tabel / tampilan , secara kolektif sumber data .
# 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'
Di Rails 2, 3 & 4 API adalah tentang tabel .
# 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'
Mendapatkan status migrasi:
# Tells you all migrations run
ActiveRecord::Migrator.get_all_versions
# Tells you the current schema version
ActiveRecord::Migrator.current_version
Jika Anda membutuhkan lebih banyak API untuk migrasi atau metadata, lihat: