heroku运行rake db:迁移错误 [英] heroku run rake db:migrate error

查看:116
本文介绍了heroku运行rake db:迁移错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 运行'rake db' :migrate` attached to terminal ... up,run.1 
DEPRECATION警告:您在供应商/插件中有Rails 2.3风格的插件!在Rails 4.0中将会删除对这些插件的支持。将它们移出并将它们捆绑到Gemfile中,或者将它们作为lib / myplugin / *和config / initializers / myplugin.rb折叠到您的应用程序中。有关更多信息,请参阅发行说明:http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released。 (从/ app / Rakefile中的< top(required)>调用:7)
DEPRECATION WARNING:在供应商/插件中有Rails 2.3风格的插件!在Rails 4.0中将会删除对这些插件的支持。将它们移出并将它们捆绑到Gemfile中,或者将它们作为lib / myplugin / *和config / initializers / myplugin.rb折叠到您的应用程序中。有关更多信息,请参阅发行说明:http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released。 (从/ app / Rakefile中的< top(required)>调用:7)
DEPRECATION WARNING:在供应商/插件中有Rails 2.3风格的插件!在Rails 4.0中将会删除对这些插件的支持。将它们移出并将它们捆绑到Gemfile中,或者将它们作为lib / myplugin / *和config / initializers / myplugin.rb折叠到您的应用程序中。有关更多信息,请参阅发行说明:http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released。 (从/ app / Rakefile中的< top(required)>调用:7)
迁移到CreateUsers(20120525005302)
迁移到DeviseCreateUsers(20120611000411)
== DeviseCreateUsers:migrating == ============================================
- create_table(:users)
rake中止!
发生错误,此次以及所有后来的迁移被取消:

PGError:ERROR:关系users已经存在
:CREATE TABLEusers(idserial primary (255)DEFAULT''NOT NULL,'encrypted_pa​​ssword'字符变化(255)DEFAULT''NOT NULL,reset_password_token字符变化(255),reset_password_sent_at时间戳,remember_created_at时间戳, sign_in_count整数DEFAULT 0,current_sign_in_at时间戳,last_sign_in_at时间戳,current_sign_in_ip字符变化(255),last_sign_in_ip字符变化(255),created_at时间戳NOT NULL,updated_at时间戳NOT NULL)
$ b任务:TOP => db:migrate

在我的github仓库中有以下迁移文件


  1. 20120525005302_create_users.rb(为空,不知道如何删除它)

  2. 20120611000411_devise_create_users.rb

  3. 20120613140535_create_authentications.rb


解决方案

看起来如下所示: p>


  • 20120525005302_create_users.rb 会尝试创建个用户 code>表中的数据库。
  • 20120611000411_devise_create_users.rb 也会尝试创建一个个用户数据库中的表。

  • 您的数据库目前已经有一个 users 表,在第二次迁移时失败。



在数据库中获取 users 正确对应 20120611000411_devise_create_users.rb migrati您可以执行以下两种操作之一:


  1. 回滚(或删除)数据库,然后再次运行迁移。 (如果它是空的,您可以删除 20120525005302_create_users.rb )。

  2. 修改您的 20120611000411_devise_create_users.rb 迁移以删除任何现有的用户表。

  3. 修改您的 20120611000411_devise_create_users.rb 迁移如下:

    • 不要创建 users 表,请修改现有表。

    • 添加和修改数据库组件以对应


通常,如果您的应用程序处于婴儿状态,那么重新创建数据库往往是构建应用程序初始结构的快捷方式。但是,如果您的用户表中已经有重要数据,那么您需要保留该数据并继续修改 20120611000411_devise_create_users.rb

参考




I want do run migration on my app that I have on heroku but I get this error:

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

I have the following migration files in my github repository

  1. 20120525005302_create_users.rb (which is empty, dont know how to remove it)
  2. 20120611000411_devise_create_users.rb
  3. 20120613140535_create_authentications.rb

解决方案

It looks like the following is true:

  • 20120525005302_create_users.rb will attempt to create a users table in your database.
  • 20120611000411_devise_create_users.rb will also attempt to create a users table in the database.
  • Your database currently already has a users table in it, so the migration fails on the second migration.

To get the users table in your database to correspond properly to the 20120611000411_devise_create_users.rb migration, you can do one of two things:

  1. Roll back (or drop) the database, and then run the migrations again. (You can delete the 20120525005302_create_users.rb if it is empty.)
  2. Modify your 20120611000411_devise_create_users.rb migration to drop any existing users table before doing anything else.
  3. Modify your 20120611000411_devise_create_users.rb migration as follows:
    • Instead of creating a users table, modify the existing table.
    • Add and modify database components to correspond

Generally, if your application is in an "infant state," then re-creating the database tends to be a quick way to build the initial structure of an application. However if you already have important data in your users table, you'll want to keep that and proceed by modifying the 20120611000411_devise_create_users.rb migration to change the database non-destructively.

References

这篇关于heroku运行rake db:迁移错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆