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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:07:06+00:00 2026-05-16T15:07:06+00:00

Hey guys, when I first begin a rails project, the model user was designed

  • 0

Hey guys, when I first begin a rails project, the model user was designed and created. After all the migration part, it successful created the table “users” at postgres.
Well, then after doing some changes during the project, I realized that was missing an attribute/new column at the table.

So what I did was delete the table users from postgres and add a new column at my first migration ruby class:

class CreateUsers < ActiveRecord::Migration
  def self.up
    create_table :users do |t|
      t.string :name
      t.string :password
      t.string :email
      t.string :authorization_token //this is the new attribute that I insert
      t.datetime :created_at
      t.datetime :updated_at

      t.timestamps
    end
  end

  def self.down
    drop_table :users
  end
end

So, when I run again the db:migrate hopping that a new user table will be created with the new attribute :authorization_token, it doesn’t work, but with no errors.

(I know that I should not remove the table, there is another smart way to do it)

  • 1 1 Answer
  • 2 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-16T15:07:07+00:00Added an answer on May 16, 2026 at 3:07 pm

    Migrations are run once & stored in the database as having been used (take a look in the schema_migrations table). You could try using rake db:migrate:reset to re-run your initial migration, but it’s better to just add new migrations (you won’t want to blow away your database when it has data in it) as follows:

    script/generate migration add_authorization_token_to_users authorization_token:string

    which will generate something similar to the following:

    class AddAuthorizationTokenToUsers < ActiveRecord::Migration
      def self.up
        change_table :users do |t|
          t.string :authorization_token //this is the new attribute that I insert
        end
      end
    
      def self.down
        remove_column :users, :authorization_token
      end
    end
    

    To see how add/remove column, change_table, etc work, take a look at ActiveRecord::ConnectionAdapters::SchemaStatements at http://api.rubyonrails.org or http://guides.rubyonrails.org/migrations.html

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

Sidebar

Related Questions

Hey guys, first off all sorry, i can't login using my yahoo provider. anyways
Hey guys! First of all, I know this kind of stuff is quite shitty,
Hey guys, quick question, just trying to filter a user's first and last name
Hey guys. I'm creating a rails app and being one of the first times
Hey guys hoping for a little help here. First I created a working map
Hey guys am having a bit of problems with my jQuery, I have all
Hey guys, this is my first time actually posting at stackflow but i've used
Hey guys, I'm very excited about how experienced I am in programming. The first,
Hey guys I have a ruby on rails app with a before filter setup
Hey guys I'm building my first website and I cannot figure how to get

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.