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

  • Home
  • SEARCH
  • 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 34489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T14:05:11+00:00 2026-05-10T14:05:11+00:00

I have a sequence of migrations in a rails app which includes the following

  • 0

I have a sequence of migrations in a rails app which includes the following steps:

  1. Create basic version of the ‘user’ model
  2. Create an instance of this model – there needs to be at least one initial user in my system so that you can log in and start using it
  3. Update the ‘user’ model to add a new field / column.

Now I’m using ‘validates_inclusion_of’ on this new field/column. This worked fine on my initial development machine, which already had a database with these migrations applied. However, if I go to a fresh machine and run all the migrations, step 2 fails, because validates_inclusion_of fails, because the field from migration 3 hasn’t been added to the model class yet.

As a workaround, I can comment out the ‘validates_…’ line, run the migrations, and uncomment it, but that’s not nice.

Better would be to re-order my migrations so the user creation (step 2) comes last, after all columns have been added.

I’m a rails newbie though, so I thought I’d ask what the preferred way to handle this situation is 🙂

  • 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. 2026-05-10T14:05:12+00:00Added an answer on May 10, 2026 at 2:05 pm

    The easiest way to avoid this issue is to use rake db:schema:load on the second machine, instead of db:migrate. rake db:schema:load uses schema.rb to load the most current version of your schema, as opposed to migrating it up form scratch.

    If you run into this issue when deploying to a production machine (where preserving data is important), you’ll probably have to consolidate your migrations into a single file without conflicts.

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

Sidebar

Related Questions

I have a sequence of SQL calls, which I want to use to detect
I have one hibernate sequence, that generates all sequence-numbers in my app. When I
If I have sequence of sequences (maybe a list of tuples) I can use
If you have a sequence of block elements and you wanted to place margin
Let's say I have a sequence of values (e.g., 3, 5, 8, 12, 15)
I have a long sequence of hex digits in a string, such as 000000000000484240FA063DE5D0B744ADBED63A81FAEA390000C8428640A43D5005BD44
I have a table that records a sequence of actions with a field that
I have a long string (a DNA sequence). It does not contain any whitespace
I have a number of tables that use the trigger/sequence column to simulate auto_increment
Hi I want to have two tables each have an INT id column which

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.