sajad torkamani

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 that you often want to know about the 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, etc?

Every little helps.

Tagged: Rails