应用的迁移条目未出现在 schema_migrations 表中

发布于 2024-12-18 13:50:51 字数 312 浏览 1 评论 0原文

我在 heroku 上有一个在生产环境中运行的应用程序,但 schema_migrations 表存在问题。

最后的迁移更改存在于 db/schema.rb 文件中,但 schema_migrations 表中没有此迁移的条目。

因此,当运行 rake db:version 时,我得到了与上次迁移之前执行的迁移相对应的编号。

我相信我应该在 schema_migrations 表上添加此迁移的条目,但我不确定如何在不影响我的数据库和远程 Heroku 上的日期的情况下执行此操作。

I got an app running in production on heroku, but there is a problem with the schema_migrations table.

The last migration changes are present at the db/schema.rb file, but there is no entry for this migration in the schema_migrations table.

So when running rake db:version I got the number corresponding to the migration executed before this last migration.

I believe i should add an entry for this migration on schema_migrations table, but i am not sure of how to do this without affecting the date on my database, and remotely on heroku.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

救赎№ 2024-12-25 13:50:51

我遇到了类似的问题,我的 schema_migrations 表中没有迁移。所以我必须运行这个:

Dir.open('db/migrate').each do |fname|
    i = fname.split('_').first.to_i
    next if i == 0
    ActiveRecord::Base.connection.execute("INSERT INTO schema_migrations (version) VALUES(#{i})")
end

source

I had a similar problem, where I had no migrations in my schema_migrations table. So I had to run this:

Dir.open('db/migrate').each do |fname|
    i = fname.split('_').first.to_i
    next if i == 0
    ActiveRecord::Base.connection.execute("INSERT INTO schema_migrations (version) VALUES(#{i})")
end

source

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文