开发者

Heroku rails migration problem

I now get the following error in git:

Home@PC /c/rails/konkurranceportalen (master)
    $ heroku rake db:migrate
    (in /app/x/home)
    ==  DeviseCreateAdmins: migrating =============================================
    -- create_table(:admins)
       -> 0.0148s
    -- add_index(:admins, :email, {:unique=>true})
       -> 0.0231s
    -- add_index(:admins, :reset_password_token, {:unique=>true})
    rake aborted!
    An error has occurre开发者_运维问答d, this and all later migrations canceled:

    PGError: ERROR:  column "reset_password_token" does not exist
    : CREATE UNIQUE INDEX "index_admins_on_reset_password_token" ON "admins" ("reset
    _password_token")

    (See full trace by running task with --trace)

I have changed the migration file in my app on my local machine. But it don't seem to change anything when I use heroku rake db:migrate. I have run git push heroku master. I can migrate the database on my local machine. I am currently using Mysql with phpmyadmin.

Do I have to change my database.yml is my app not pushed to heroku?

Here is some of my database.yml :

    production:
      adapter: mysql
      database: rails_p
      encoding: utf8
      pool: 5
      username: root
      password: 
      socket: C:/xampp/mysql/bin/mysqld.sock
      host: 127.0.0.1

My migration:

class DeviseCreateAdmins < ActiveRecord::Migration
  def self.up
    create_table(:admins) do |t|
      t.database_authenticatable :null => false
      t.rememberable
      t.timestamps
    end

    add_index :admins, :email,                :unique => true
    # add_index :admins, :confirmation_token,   :unique => true
    # add_index :admins, :unlock_token,         :unique => true
  end

  def self.down
    drop_table :admins
  end
end


It could be that the error is happening on a different migration, as you're not including devise recoverable column, and your script doesn't reference the column *reset_password_token*

Could it be that you want to run the following script?

class DeviseCreateUsers < ActiveRecord::Migration
  def self.up
    create_table(:users) do |t|
      t.database_authenticatable :null => false
      t.recoverable
      t.rememberable   
      t.timestamps
    end

    add_index :users, :email,                :unique => true
    add_index :users, :reset_password_token, :unique => true
  end

  def self.down
    drop_table :users
  end
end

Remember that when you use heroku you push your git repository, so if you have uncommitted changes (as you've mentioned), heroku won't see them.


git commit -a -m "updated some files"

Then git push heroku master

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜