A quick way to check your Rails database schema
Sometimes, we need to check what our database schema looks like. Instead of spinning up a database GUI tool like MySQL Workbench and doing a few clicks (or a whole lot of clicks if using pgAdmin!), you can view the
db/schema.rb file that Rails maintains for you.
This file should tell you most of the wonderful things you typically need to know about your database schema.
- List of tables
- The columns making up each table
- Properties of each column – is it a primary key, a foreign key, nullable, unique, indexable, the meaning of life, etc?
So much fun.