Rails 迁移版本问题:任何新迁移都不起作用

发布于 2025-01-02 05:45:11 字数 1319 浏览 0 评论 0原文

从今天早上开始,我遇到了 Rails 设备的奇怪问题。以下是我的 ls 和 rake db version 命令的输出。

hrishikesh@hrishikesh-ubuntu:~/git-public/personaldiary/db/migrate$ ls -1
20120110083934_devise_create_users.rb
20120110090514_create_posts.rb
20120110090845_add_user_id_to_post.rb
20120203035323_add_confirmable_to_devise.rb
20120203035323_add_confirmable_to_devise.rb~
20120203043601_add_lockable_to_devise.rb
20120203043601_add_lockable_to_devise.rb~
hrishikesh@hrishikesh-ubuntu:~/git-public/personaldiary/db/migrate$ rake db:version
(in /home/hrishikesh/git-public/personaldiary)
DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead. (called from /usr/lib/ruby/vendor_ruby/activerecord.rb:2)
Current version: 20120203034555
hrishikesh@hrishikesh-ubuntu:~/git-public/personaldiary/db/migrate$ 

如果我尝试添加任何新的迁移,rake db:migrate 会抛出错误,告诉我某些列已经存在,然后失败。

我失败的迁移代码在这里:

class AddConfirmableToDevise < ActiveRecord::Migration
  def change
    change_table(:users) do |t|
      t.confirmable
    end
    add_index :users, :confirmation_token,   :unique => true
  end
end

我特别不想使用向上和向下方法,因为 这个

请帮忙。

From this morning, I am facing weird issues with Rails devise. Following is output of my ls and rake db version command.

hrishikesh@hrishikesh-ubuntu:~/git-public/personaldiary/db/migrate$ ls -1
20120110083934_devise_create_users.rb
20120110090514_create_posts.rb
20120110090845_add_user_id_to_post.rb
20120203035323_add_confirmable_to_devise.rb
20120203035323_add_confirmable_to_devise.rb~
20120203043601_add_lockable_to_devise.rb
20120203043601_add_lockable_to_devise.rb~
hrishikesh@hrishikesh-ubuntu:~/git-public/personaldiary/db/migrate$ rake db:version
(in /home/hrishikesh/git-public/personaldiary)
DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead. (called from /usr/lib/ruby/vendor_ruby/activerecord.rb:2)
Current version: 20120203034555
hrishikesh@hrishikesh-ubuntu:~/git-public/personaldiary/db/migrate$ 

If I try to add any new migrations, rake db:migrate throws error that tells me that some column already exists, and fails.

My failing migration code is here:

class AddConfirmableToDevise < ActiveRecord::Migration
  def change
    change_table(:users) do |t|
      t.confirmable
    end
    add_index :users, :confirmation_token,   :unique => true
  end
end

I specifically do not want to use up and down methods because of this

Please help.

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

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

发布评论

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

评论(1

未央 2025-01-09 05:45:11

在花了几个小时寻找解决方案后,我决定放弃并运行

rake db:migrate:reset

它,它起作用了,唯一的问题是我的数据丢失了,在这一点上这并不是什么大问题。

感谢大家尝试解决这个问题。

After spending hours to find solution, I decided to give up and ran

rake db:migrate:reset

And it worked, only thing is my data was lost, which was not that big deal at this point.

Thank you everyone for attempting to solve this.

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