【发布时间】:2013-05-21 10:12:26
【问题描述】:
您好,我目前正在学习 Rails,并且正在学习教程。说明是在我创建应用程序后编辑迁移文件,然后运行 rake db:migrate,然后运行 rake db:create。
我已将迁移文件编辑为:
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :username
t.string :email
t.string :encrypted_password
t.string :salt
t.timestamps
end
end
end
然后当我运行“rake db:migrate”时出现错误
Mysql2::Error: Table 'users' already exists: CREATE TABLE `users` ...
在我应该运行“rake db:create”之后,我得到了这个
user_auth_development already exists
user_auth_test already exists
【问题讨论】:
-
我需要运行 db:create 和 db:migrate 吗?还是在我编辑迁移文件后就已经设置好了?
-
表示表已经存在。可能是以前的迁移已经创建了它。
标签: ruby-on-rails database migrate