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 8411377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:24:30+00:00 2026-06-10T00:24:30+00:00

According to Rails doc: http://guides.rubyonrails.org/migrations.html Active Record tracks which migrations have already been run

  • 0

According to Rails doc: http://guides.rubyonrails.org/migrations.html

“Active Record tracks which migrations have already been run so all you have to do is update your source and run rake db:migrate.”

How does ActiveRecord actually do this? Where does Active Record store the data?

I suspect this might be stored in the database itself? In a table somewhere.

On my development machine, I ran all the migrations. Then I copied the production database over using mysqldump. Then I ran “rake db:migrate:status”, it shows correctly the migrations that need to run on the production database.

I used to think that ActiveRecord keeps track of the last migration run using the timestamp. But I think this is not true because ActiveRecord correctly runs the “older” migrations merged in from another code branch.

Could someone with inside knowledge of this elaborate?
Thanks

  • 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-06-10T00:24:31+00:00Added an answer on June 10, 2026 at 12:24 am

    Rails creates a table in your database called schema_migrations to keep track of which migrations have run.

    The table contains a single column, version. When Rails runs a migration, it takes the leading digits in the migration’s file name and inserts a row for that “version”, indicating it has been run. If you roll back that migration, Rails will delete the corresponding row from schema_migrations.

    For example, running a migration file named 20120620193144_create_users.rb will insert a new row with a version of 20120620193144 into the schema_migrations table.

    You are free at any point to introduce migrations with earlier versions. Rails will always run any new migrations for which there is not a corresponding row in schema_migrations. The leading digits don’t have to be a timestamp, you could call your migration 001_blah.rb. Earlier versions of Rails used this format, and used sequential numbering for newly generated migrations. Later versions have switched to timestamps to help prevent multiple developers from independently generating migrations with the same number.

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

Sidebar

Related Questions

Rails 3.0.9 I configured routes according to http://guides.rubyonrails.org/i18n.html#setting-the-locale-from-the-url-params But seems that info there is
According to http://edgeapi.rubyonrails.org/classes/Rails/Railtie.html , if I write a Rails 3 plugin and I want
I'm using gem rapns (https://github.com/ileitch/rapns) on my rails app. According to rapns doc, I
I have Rails polymorphic model and I want to apply different validations according to
I have a Rails app which allows users to upload Excel files which need
I am following the Ruby on Rails Tutorial (http://ruby.railstutorial.org) . In Chapter 3, the
according to this (older) post these Rails 3 finders have race conditions. Something like
According to Simone Carletti blog post , Rails 3 ajax helpers have changed a
I'm wondering if there's any way for a Rails asset to vary according to
My rails app, according to my heroku logs, is serving requests on average of

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.