rake db:migrate错误表

编程入门 行业动态 更新时间:2024-10-12 22:29:41
本文介绍了rake db:migrate错误表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试运行 rake db:migrate ,并在控制台中收到错误。

似乎我正在创建一个已经存在的表,但我不知道如何删除旧表,或者重置db以开始新鲜。 / p>

我没有任何用户如此擦除或从新鲜开始不会是一个问题。

create_table(:users)rake aborted! StandardError:一个错误发生,这个和所有后来的迁移被取消:

SQLite3 :: SQLException:表users已经存在:CREATE TABLE users(idINTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,email varchar(255)DEFAULT''NOT NULL,encrypted_pa​​sswordvarchar(255) DEFAULT''NOT NULL, reset_password_tokenvarchar(255),reset_password_sent_atdatetime,remember_created_atdatetime,sign_in_countinteger DEFAULT 0 NOT NULL,current_sign_in_at datetime,last_sign_in_atdatetime,current_sign_in_ip varchar(255),last_sign_in_ipvarchar(255),created_atdatetime,updated_atdatetime) /Users/jovanhernandez/.rvm/gems/ruby-2.1。 2 / gems / sqlite3-1.3.9 / lib / sqlite3 / database.rb:91:in `initialize'

解决方案

如果您不介意删除数据,您可以运行

rake db:drop rake d b:创建 rake db:migrate

,应该修复它。否则,您可以暂时注释掉部分内容,导致迁移中的更改(或向上)方法出现问题,然后运行迁移。迁移后,迁移将被移除。

执行此操作可以接受迁移是最新的。

I am trying to run rake db:migrate and am receiving an error in the console.

It seems as though I am creating a table that already exists, yet I don't know how to remove the old table, or reset the db to start fresh.

I don't have any users so erasing or starting from fresh won't be an issue.

create_table(:users) rake aborted! StandardError: An error has occurred, this and all later migrations canceled:

SQLite3::SQLException: table "users" already exists: CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar(255) DEFAULT '' NOT NULL, "encrypted_password" varchar(255) DEFAULT '' NOT NULL, "reset_password_token" varchar(255), "reset_password_sent_at" datetime, "remember_created_at" datetime, "sign_in_count" integer DEFAULT 0 NOT NULL, "current_sign_in_at" datetime, "last_sign_in_at" datetime, "current_sign_in_ip" varchar(255), "last_sign_in_ip" varchar(255), "created_at" datetime, "updated_at" datetime) /Users/jovanhernandez/.rvm/gems/ruby-2.1.2/gems/sqlite3-1.3.9/lib/sqlite3/database.rb:91:in `initialize'

解决方案

If you don't mind erasing data you can run

rake db:drop rake db:create rake db:migrate

and that should fix it. Otherwise you can for the moment comment out the part of the content causing problems in the change (or up) method in your migration and then run the migrations. After the migration is run uncomment the migration.

Doing this tricks rails into accepting that the migrations are up to date.

更多推荐

rake db:migrate错误表

本文发布于:2023-10-18 15:08:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1504588.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   rake   db   migrate

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!