Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7700133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:38:17+00:00 2026-05-31T22:38:17+00:00

I used to think the db/schema.rb in a Rails project stored the database schema,

  • 0

I used to think the db/schema.rb in a Rails project stored the database schema, so that ActiveRecord can know what table/column it has.

But earlier I surprisingly noticed that my project runs normally after I delete db/schema.rb!

So, since the Rails can work without it, what does schema.rb really do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:38:18+00:00Added an answer on May 31, 2026 at 10:38 pm

    The schema.rb serves mainly two purposes:

    1. It documents the final current state of the database schema. Often, especially when you have more than a couple of migrations, it’s hard to deduce the schema just from the migrations alone. With a present schema.rb, you can just have a look there. ActiveRecord itself will indeed not use it. It will introspect the database during runtime as this is much safer than to expect users to keep the schema.rb up-to-date. However to avoid confusion of your developers, you should always maintain a file that is up-to-date with your migrations.

    2. It is used by the tests to populate the database schema. As such a rake db:schema:dump is often run as part of the rake test:prepare run. The purpose is that the schema of the test database exactly matches the current development database.

    In addition to that, some people use the schema.rb to load the final schema into a database to avoid having to run a long list of migrations to setup a fresh database. This is sometimes necessary if you have an application where the previous migrations can not run cleanly with the rest of the application (e.g. because model definitions have changed between the time the migrations were added compared to the current state).

    Generally however, I would recommend to keep the migrations up-to-date with the rest of the application so that you can always start with just the migrations rather than replying on schema.rb to avoid multiple and potentially diverging "sources of truth".

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using schema.rb , I think we can actually convert an older Rails 3.0 project
So... I used to think that when you accessed a file but specified the
I think I may misunderstand why the with command is used. But can any
A recent question contains a problem that I many times used to think about
I think that it used to the be the case that in Liferay 4,
I think the following code can be used to create manipulators. #include<iostream> ostream &
I think that I've been used to a fairly liberal policy regarding the PHP
There is an Oracle database schema (very small in data, but still about 10-15
I've just been handed a database schema that looks a little odd to me.
I need a string->string mapping to be used at runtime (think NSDictionary ), except

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.