Heroku运行rake db:在数据库中迁移结果不变,应用程序重新启动几次 [英] Heroku run rake db:migrate results in no change in the database, app restarted several times
问题描述
问题:
- $
- 我通过添加1列来更改数据库模式。
-
我已将它迁移到生产数据库:
MacBook-Air-Mac:app msc $ rake db:migrate RAILS_ENV =production
[RailsAdmin]默认情况下,RailsAdmin初始化被禁用。如果您需要,传递SKIP_RAILS_ADMIN_INITIALIZER = false。
== AddLengthColumnToBooks:迁移=========================================
- add_column(:books,:length,:integer)
- > 0.0017s
== AddLengthColumnToBooks:migrated(0.0019s)============ ==================== -
考虑到新的数据库模式现已投入生产,我已经部署了一些代码,它可以处理
:length
。 在生产中,我得到了以下错误: -
然后将应用降级到最新的可靠版本。
-
THEN(可能有点太晚了)我发现了我必须
heroku restart
应用程序加载新的索引。 我打开了控制台,然后选中 -
我做了
heroku run rake db:migrate
后跟heroku restart
多一次,没有变化。 尝试将另一列转移到生产数据库,但根本没有收到任何消息,甚至没有收到第2页的消息。 strong>更新 -
要提交的更改:
(使用git reset HEAD ...停用)
新文件:db / migrate / 20130325103953_add_length_column_to_books.rb
新文件:db / migrate / 20130401041910_add_duration_column_to_books.rb
修改:db / schema.rb -
然后我做了
git commit -m更新模式
。 - <输出结果如下:
$ p $3个文件已更改,168个插入(+),156个删除( - )
创建模式100644 db / migrate / 20130325103953_add_length_column_to_books.rb
创建模式100644 db / migrate / 20130401041910_add_duration_column_to_books.rb -
然后运行
heroku运行rake db:migrate
。不幸的是,没有迁移的迹象,只是得到了:
运行
rake db:migrate
连接到终端...在生产Rails控制台中,运行Book.column_names $>,运行5428
就是这样。 c $ c>仍然缺乏长度和持续时间。 - 对本地代码进行更改
- 运行任何迁移LOCALLY
li>
- 将所有已更改的文件添加到Git
git add。
- c $ c> git commit -m添加功能
- 将更改推送到Heroku
git push heroku master
- 假设您使用heroku
作为您的远程名称,并且您在master
分支中工作
- 如果您有迁移运行
heroku运行rake db:migrate
以运行迁移到ON HEROKU
- 迁移后做
heroku重启
- I've altered database schema by adding 1 column.
I've migrated it to the production database:
MacBook-Air-Mac:app msc$ rake db:migrate RAILS_ENV="production" [RailsAdmin] RailsAdmin initialization disabled by default. Pass SKIP_RAILS_ADMIN_INITIALIZER=false if you need it. == AddLengthColumnToBooks: migrating ========================================= -- add_column(:books, :length, :integer) -> 0.0017s == AddLengthColumnToBooks: migrated (0.0019s) ================================
Thinking that the new DB schema is now in production, I've deployed the code which does some things with
:length
.In production, I got the following error:
undefined method `length=' for #
I did
heroku rollback
and downgraded the app to the latest reliable version.THEN (a bit too late probably) I found out that I have to
heroku restart
the app to load the new indexes. I did this several times.I opened the console then and checked
Book.column_names
, but there was nolength
I did
heroku run rake db:migrate
followed byheroku restart
one more time, no change.I've tried migrating another column to the production db, but didn't get any message at all, not even the one from p.2.
git add db/schema.rb
,git add db/migrate/20130325103953_add_length_column_to_books.rb
and 'git add db/migrate/20130401041910_add_duration_column_to_books.rb'. Git's answer was:Changes to be committed: (use "git reset HEAD ..." to unstage)
new file: db/migrate/20130325103953_add_length_column_to_books.rb new file: db/migrate/20130401041910_add_duration_column_to_books.rb modified: db/schema.rb
Then I did
git commit -m "Updating the schema"
.Again the output was:
3 files changed, 168 insertions(+), 156 deletions(-)
create mode 100644 db/migrate/20130325103953_add_length_column_to_books.rb create mode 100644 db/migrate/20130401041910_add_duration_column_to_books.rb
Then I run
heroku run rake db:migrate
. Unfortunately there was no sign of migrations, simply got:Running
rake db:migrate
attached to terminal... up, run.5428 and that's it.In the production Rails Console, running
Book.column_names
still lacks both length and duration.- Make changes to local code
- Run any migrations LOCALLY
- Add all changed files to Git
git add .
- Commit all added files to git
git commit -m "Adding features"
- Push the changes to Heroku
git push heroku master
- assuming you are usingheroku
as your remote name and you are working in themaster
branch - If you have migrations run
heroku run rake db:migrate
to run the migrations ON HEROKU - Following migrations do
heroku restart
未定义的方法`length ='for#
Book.column_names
,但在那里没有长度
根据菲利普< a>,我做了一些额外的步骤: 现在我甚至更没有想法。 看起来你并没有将改动推向Heroku。步骤如下: 这应该是你需要的所有工作。 I have a problem with pushing my migrations to the production database. The issue:
Update Based on the answers of Philipe, I did a number of additional steps: Now I'm even more out of ideas.
` It doesn't look like you are pushing changes to Heroku. Steps should be as follows; That should be all you need to get you working. 这篇关于Heroku运行rake db:在数据库中迁移结果不变,应用程序重新启动几次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
$ ol
$ li $ git add db / schema.rb , git add db / migrate / 20130325103953_add_length_column_to_books.rb
和'git add db / migrate / 20130401041910_add_duration_column_to_books.rb'。 Git的答案是:
`
$ b
What am I doing wrong here?