scan, list, describe, hover and er read Rails schemas as well as Django, SQLAlchemy, Prisma and Drizzle models, and so do the MCP tools list_apps, list_models, describe_model, find_relations and er_diagram. They read db/schema.rb, the file Active Record writes after every db:migrate: it lists every table with its columns and indexes, then every foreign key. It is read as text, with no Ruby, no Rails and no database.
uvx orm-lens scan -f table # every table in db/schema.rb
uvx orm-lens er -f dbml # ER diagram: mermaid, dbml, d2, plantuml or dot
uvx orm-lens describe statuses # one table: columns, keys and what each does on delete
The diagram shows the foreign keys the database has. Associations declared only in the model classes (belongs_to, has_many) are not read, so an app that keeps its relations in Ruby without add_foreign_key shows fewer edges than it has. A project that dumps db/structure.sql instead of schema.rb shows nothing yet. The other commands don’t read Rails, and neither does the VS Code extension. The Django analyses never see a Rails table, and a Python relation never points at one.
Every schema.rb and <name>_schema.rb in a db directory that starts with ActiveRecord::Schema. Rails 8 keeps one per database (db/queue_schema.rb, db/cache_schema.rb, db/cable_schema.rb), and each is an app of its own. Files in vendor, node_modules, tmp, log, dist, build, test directories (test, tests, spec, so the spec/dummy apps of engines too) and hidden directories are skipped, and so are symlinks that lead outside the workspace.
In a workspace with no Django or SQLAlchemy project, the MCP server looks for db/schema.rb at most four directories down. If yours is deeper, point workspace_root at a directory closer to it. The CLI has no such limit.
Tables are listed under their table name. A name with a character other than a letter, digit or _ ("audit.events") becomes audit_events, so app.Model still names one table; tableName keeps the real name.
Primary keys follow create_table: the id column it adds (bigint, or the type in id: :uuid or id: { type: :string, limit: 32 }), the column in primary_key: "account_id", the columns in primary_key: [...], or none with id: false. The added column is listed first, at the line of create_table, and a composite key is also in meta.
Columns keep the type the schema names, with limit for strings, precision and scale for decimals, and [] for arrays; a virtual column has the type it is stored as, and a t.column the SQL type it names (enum(...) on MySQL). args reads NOT NULL, UNIQUE and DEFAULT ...: the default as written in Ruby ("", 0, []), or the SQL of a lambda (-> { "gen_random_uuid()" }). A column is unique when a unique index or constraint covers it alone: an index on an expression or with a where: doesn’t count.
Foreign keys come from add_foreign_key. schema.rb leaves out column: when it is the target table’s singular followed by _id, so the singular is worked out (accounts → account_id, people → person_id, categories → category_id, admin_people → admin_person_id) and checked against the table’s columns. The key is shown on its column as a ForeignKey, or as a OneToOneField when the column is the primary key or unique; primary_key: is the column it points at. Composite keys and keys that share a column are kept, as for Drizzle.
Delete policy is on_delete:: :cascade is CASCADE, :nullify is SET_NULL, :restrict is RESTRICT, and without it the database takes no action (NO_ACTION). dependent: :destroy in a model is Ruby, not the database, and is not shown.
A db/schema.rb belongs to the directory that holds db/: apps/api/db/schema.rb is api, and one at the repository root is rails. Another database’s schema adds its name: db/queue_schema.rb is queue. When that name isn’t unique, or another app already has it, the schema is named after its path instead. Relations always stay inside their own schema.
orm-lens scan --format json marks these models with "orm": "rails" and adds tableName. Django models serialize exactly as before.
The db/schema.rb of Mastodon, Forem, Chatwoot, Maybe, Lobsters, Consul Democracy, Open Food Network, rubygems.org and Campfire were read and compared with a separate count over the same text. All 777 tables and 671 foreign keys were found, with every declared column, the column of every foreign key that leaves out column:, its target table and on_delete, and the DBML diagram has one reference per foreign key. On the 29 Django and SQLAlchemy projects used for parser changes the output is the same as before.