简体   繁体   English

Rails 3:“架构迁移表尚不存在”

[英]Rails 3: “Schema migrations table does not exists yet”

So some months ago, for some reason I got a weird git message and was afraid to deploy. 所以几个月前,由于某些原因,我得到了一个奇怪的git消息,并且害怕部署。 So I started making changes to the production application directly and trying to also manually make the same changes to my local code. 所以我开始直接对生产应用程序进行更改,并尝试手动对本地代码进行相同的更改。

So now the time came to update everything, I wanted to sync my local code with the production code and start using git and capistrano to deploy again. 所以现在是更新所有内容的时候了,我想将本地代码与生产代码同步并开始使用git和capistrano再次进行部署。 So I downloaded the code from the production server and copy pasted some files into my local code to make sure I wasn't going to overwrite anything on the production server. 所以我从生产服务器下载了代码并将一些文件复制粘贴到我的本地代码中,以确保我不会覆盖生产服务器上的任何内容。

I'm now able to run cap:deploy and everything seems to work as expected. 我现在能够运行cap:deploy ,一切似乎按预期工作。 Problem is, I created a new column on my dev copy and I was about to run cap deploy:migrate but I'm afraid it's going to wipe out my production database. 问题是,我在我的开发副本上创建了一个新列,我即将运行cap deploy:migrate但是我担心它会消灭我的生产数据库。

So I ran rake db:migrate:status and I get the message Schema migrations table does not exists yet. 所以我运行rake db:migrate:status并且我收到消息Schema migrations table does not exists yet. I already checked my production database and the schema migrations table IS there. 我已经检查了我的生产数据库和架构迁移表。 So it seems the app is not recognizing my current migration version and I'm afraid that if I run cap deploy:migrate is going to run ALL the migrations and wipe out my database. 因此,似乎该应用程序无法识别我当前的迁移版本,我担心如果我运行cap deploy:migrate将运行所有迁移并清除我的数据库。

Why am I getting this message? 为什么我收到此消息? What should I do? 我该怎么办?

My situation may be somewhat different from you but I too got the same message. 我的情况可能与你有些不同,但我也得到了同样的信息。 I was in development in my local PC with Rails 4. 我正在使用Rails 4在我的本地PC上进行开发。

Try using only db:migrate . 尝试仅使用db:migrate

A solution I've found is to use abort_if_pending_migrations: 我发现的解决方案是使用abort_if_pending_migrations:

export RAILS_ENV=production; bundle exec rake db:abort_if_pending_migrations

This seems to print nothing if your migrations are up-to-date, and list tables that need updating if they are not. 如果您的迁移是最新的,那么这似乎什么都不打印,如果不是,则列出需要更新的表。 This is with Rails 4.1.8. 这是使用Rails 4.1.8。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM