我想在我的应用程序上运行我在heroku上的迁移,但是我收到了这个错误:
Running `rake db:migrate` attached to terminal... up, run.1
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
Migrating to CreateUsers (20120525005302)
Migrating to DeviseCreateUsers (20120611000411)
== DeviseCreateUsers: migrating ==============================================
-- create_table(:users)
rake aborted!
An error has occurred, this and all later migrations canceled:
PGError: ERROR: relation "users" already exists
: CREATE TABLE "users" ("id" serial primary key, "email" character varying(255) DEFAULT '' NOT NULL, "encrypted_password" character varying(255) DEFAULT '' NOT NULL, "reset_password_token" character varying(255), "reset_password_sent_at" timestamp, "remember_created_at" timestamp, "sign_in_count" integer DEFAULT 0, "current_sign_in_at" timestamp, "last_sign_in_at" timestamp, "current_sign_in_ip" character varying(255), "last_sign_in_ip" character varying(255), "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
Tasks: TOP => db:migrate
我的github存储库中有以下迁移文件
答案 0 :(得分:2)
看起来如下:
20120525005302_create_users.rb
将尝试在您的数据库中创建users
表。20120611000411_devise_create_users.rb
还将尝试在数据库中创建users
表。users
表,因此迁移在第二次迁移时失败。要使数据库中的users
表与20120611000411_devise_create_users.rb
迁移正确对应,您可以执行以下两项操作之一:
20120525005302_create_users.rb
为空,您可以将其删除。)20120611000411_devise_create_users.rb
迁移,以便在执行任何其他操作之前删除任何现有的users
表。20120611000411_devise_create_users.rb
迁移,如下所示:
users
表,而是修改现有表。通常,如果您的应用程序处于“婴儿状态”,那么重新创建数据库往往是构建应用程序初始结构的快速方法。但是,如果您的users
表中已有重要数据,则需要保留该数据并继续修改20120611000411_devise_create_users.rb
迁移以非破坏性地更改数据库。
<强>参考强>
答案 1 :(得分:1)
看起来你已经有了table_create_users尝试重新创建的表用户(可能来自create_users migration)
您可以修改create_device_users迁移,只需添加所需的字段
或者,如果它是一个没有用户的全新应用程序,您可以放弃并尝试重新运行所有迁移