0

I wanted to be more specific in my "user" table. I created a migration called "location" and then realized I wanted "state" and "city" instead. The location migration was fine but then when I changed the name I accidently changed the type to state instead of the name. Well, I figured I would then just run a new migration and change the type back to text and then rename the column. Thats where I ran into some errors. I'm currently getting this in terminal

undefined method `to_sym' for nil:NilClass/usr/local/rvm/gems/ruby-2.1.1/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/schema_definitions.rb:216:in `column'

migration status

Status   Migration ID    Migration Name
--------------------------------------------------
   up     20140710145422  Devise create users
   up     20140710145425  Add name to users
   up     20140710145432  Add role to users
   up     20140710201635  Create books
   up     20140710204116  Create pits
   up     20140715181941  Add author to books
   up     20140729005134  Fix column name
   up     20140729005452  Add columnto users
   up     20140730031957  Add topic to pit
   up     20140730032046  Add image to pit
   up     20140730032123  Add video to pit
   up     20140730204604  Add summary to pits
   up     20140810150735  Add author to pits
   up     20140810192646  Add about to users
   up     20140811060108  Create comments
   up     20140811184800  Add column to pits
   up     20140819182243  Acts as votable migration
   up     20140822173255  Add location to users
   up     20140822181121  Change user location
  down    20140822181813  Change location field

Last three migration files

class AddLocationToUsers < ActiveRecord::Migration
  def change
    add_column :users, :location, :string
  end
end

class ChangeUserLocation < ActiveRecord::Migration
  def change
    change_column :users, :location, :state
  end
end


class ChangeLocationField < ActiveRecord::Migration
  def change
    change_column :users, :location, :string
  end
end

I tried rake db:rollback and even tried dropping and recreating the database which provided the same error as above. I'm using devise as well if that makes a difference. I basically can't do anything and I'm stuck. I just want to change location "type" to text and the rename that column after the fact to "city". Using SQlite. Would love some help here. Thanks

Mark Hustad
  • 169
  • 1
  • 14

1 Answers1

1

So fixed the issue when I ended up reverting back to an older migration prior to the migration that was causing the issue via rake db:migrate VERSION=XXXXXXXXXXXX. Props to this post here

How to delete migration files in Rails 3

Community
  • 1
  • 1
Mark Hustad
  • 169
  • 1
  • 14