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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:32:25+00:00 2026-05-26T15:32:25+00:00

I have the following migration: def self.up add_column :project_statuses, :system_sequence, :integer, :default => 0,

  • 0

I have the following migration:

def self.up
  add_column :project_statuses, :system_sequence, :integer, :default => 0, :null => false

  ProjectStatus.create :name => 'Declined', :sequence => 35, :system_sequence => 110

  ...
end

But when I do a rake db:create, rake db:migrate, I get the following error:

==  NewProjectStatuses: migrating =============================================
-- add_column(:project_statuses, :system_sequence, :integer, {:default=>0, :null=>false})
   -> 0.0029s
rake aborted!
An error has occurred, this and all later migrations canceled:

unknown attribute: system_sequence
/Users/ttt/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activerecord-3.1.1/lib/active_record/base.rb:1753:in `block in assign_attributes'
/Users/ttt/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activerecord-3.1.1/lib/active_record/base.rb:1747:in `each'
/Users/ttt/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activerecord-3.1.1/lib/active_record/base.rb:1747:in `assign_attributes'
/Users/ttt/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activerecord-3.1.1/lib/active_record/base.rb:1567:in `initialize'
/Users/ttt/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activerecord-3.1.1/lib/active_record/base.rb:508:in `new'
/Users/ttt/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/activerecord-3.1.1/lib/active_record/base.rb:508:in `create'
/[working dir]/db/migrate/20100816100139_new_project_statuses.rb:7:in `up'

The erroneous line number refers to the Project.create :name => ... line.

It seems like the add_column line isn’t run at all, even though the output says it is run.

Running a rake db:migrate again runs through the migrations fine though.

Why is this?

  • 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-26T15:32:26+00:00Added an answer on May 26, 2026 at 3:32 pm

    Try calling ProjectStatus.reset_column_information after the add_column block.

    Rails caches column information (including which columns exist), and I believe what you’re hitting here is that you’re creating a column, but that doesn’t trigger Rails to reset its cache on the list of available columns. As a result, your following line fails, because it doesn’t think the column exists.

    I’m not sure why the caching is designed this way, but this sort of thing is explicitly mentioned in the example code regarding the use of reset_column_information. I think there’s a pretty good chance that’s the issue.

    That being said, I also generally agree with Michael Durrant, regarding the use of filling the DB with values via migrations. The preferred method is to add your default/seed data to a rake task (which can be run at any arbitrary time), or your seeds.rb file. This is in contrast to a migration, which is only run when the current schema version is older than the specified migration.

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

Sidebar

Related Questions

For example I have the following migration class AddStatusField < ActiveRecord::Migration def self.up add_column
I have the following ActiveRecord migration: class CreateSubjects < ActiveRecord::Migration def self.up create_table :subjects
I have the following Rails model: class CreateFoo < ActiveRecord::Migration def self.up create_table :foo
I have the following rails migration: create_table :articles do |t| t.integer :user_id, :allow_null =>
I have the following migration and I want to be able to check if
I have an ExpenseType object that I have created with the following migration: class
I have a sequence of migrations in a rails app which includes the following
I have following situation: I have loged user, standard authentication with DB table $authAdapter
I have following string String str = replace :) :) with some other string;
I have following foreach-loop: using System.IO; //... if (Directory.Exists(path)) { foreach(string strFile in Directory.GetFiles(path,

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.