Heroku Rails 迁移问题
我现在在 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 occurred, 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)
我已更改本地计算机上应用程序中的迁移文件。但当我使用 heroku rake db:migrate 时,它似乎没有改变任何东西。我已经运行 git push heroku master 。 我可以迁移本地计算机上的数据库。我目前正在使用 Mysql 和 phpmyadmin。
我是否必须更改我的database.yml,我的应用程序没有推送到heroku?
这是我的一些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
我的迁移:
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
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 occurred, 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
错误可能发生在不同的迁移上,因为您没有包含 devise recoverable 列,并且您的脚本没有引用列 *reset_password_token*
您是否想要运行下面的脚本?
请记住,当您使用 heroku 时,您会推送 git 存储库,因此如果您有未提交的更改(如您所提到的),heroku 将不会看到它们。
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?
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 Push heroku master
Then git push heroku master