Import Rails schema.rb

Paste your Rails app's db/schema.rb into DrawSQL and get an ERD of your whole app — Rails shorthand like t.references and t.timestamps is expanded into the real columns, indexes, and relationships it creates.

Grab your schema file

It's already in your repo at db/schema.rb — Rails keeps it current every time you migrate. To regenerate it from your database:

 bin/rails db:schema:dump

App uses db/structure.sql instead (schema_format = :sql)? Import that file with the SQL import — it works the same way.

Import it

  1. In the diagram editor, click FileImport — or open the /draw playground to try it without an account.

  2. Paste the file, upload it — or switch to the GitHub tab and paste your repo's URL. For public repos, DrawSQL finds db/schema.rb on its own.

  3. Click Begin Import and review the log.

DrawSQL detects whether the schema came from MySQL or PostgreSQL and resolves column types for that DBMS. Importing into an existing diagram uses the diagram's DBMS; on /draw you can override the target with the into <DBMS> control.

What gets imported

  • Every create_table block — including the implicit id primary key, UUID primary keys, and id: false tables

  • t.timestampscreated_at and updated_at

  • t.references / t.belongs_to → the _id column with its index, plus a relationship when a foreign key is defined

  • add_foreign_key statements — drawn as relationships

  • Indexes, including unique and multi-column ones

  • Composite primary keys (Rails 7.1+)

Known limits

Anything that can't be represented is skipped and flagged in the import log:

  • Polymorphic references import their _id and _type columns, but no relationship line — there's no single target table to point at

  • Partial (where:) and expression indexes

  • Type modifiers like limit, precision, and scale — the base type is kept

  • Ridgepole Schemafiles — they look like schema.rb but are arbitrary Ruby, and aren't supported

Still have a question? We'd love to help!