Rails 项目部署 production 遇到一个问题,请教!

shin · July 16, 2014 · Last by shin replied at July 17, 2014 · 2866 hits

在 development 运行良好,今天在RAILS_ENV=production rake db:create db:migrate时报错

== 20140623055658 AddRentEnvToSearches: migrating =============================
-- add_column(:searches, :rent_env_id, :integer)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

SQLite3::SQLException: no such table: searches: ALTER TABLE "searches" ADD "rent_env_id" integer

是这个迁移文件没找到吗?

不知道问题点出在哪里?请教大家!

no such table: searches: ALTER TABLE "searches" ADD "rent_env_id" integer

没找到这个表。。。。

大概是创建这个表的迁移文件你弄丢了

@colorfulberry 那怎么弥补?但在 migrating 文件夹里这个 20140623055658 迁移文件是有的~

#4 楼 @shin 先创建表啊 没表 怎么向表里加字段

#4 楼 @shin 不是 20140623055658 迁移文件不见了,而是创建“searches”表的这个迁移文件不见了,因此你需要先创建一个“searches”表

Production 用 SQLite3。。。。

好了!谢谢各位。个人测试项目,SQlite 问题不大。

@shin rake db:migration:down VERSION 那个创建的迁移文件 然后把 down 改成 up 应该就好了

先看看 schema.rb 文件里面有没有 searches, 或者 searches 写错成了单数, 再检查下 schema_migrations 表里面的记录,看看是不是漏了哪条 migration。

@MrPasserby schema.rb 里有 searches 表。然后我 rake db:reset 一下,再RAILS_ENV=production rake db:create db:migrate就好了!

You need to Sign in before reply, if you don't have an account, please Sign up first.