gpt4 book ai didi

mysql - Rails - 没有这样的表 [rake db :migrate]

转载 作者:搜寻专家 更新时间:2023-10-30 22:12:45 26 4
gpt4 key购买 nike

我的 Rails 数据库有问题。我最近恢复到以前的提交,我正在尝试通过服务器和数据库启动并运行。

我运行了 rake db:migrate 和 'rake db:create',它们都返回相似的结果

知道如何解决吗?

rake aborted!
An error has occurred, this and all later migrations canceled:
SQLite3::SQLException: no such table: main.users: CREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email")/Users/Marcus/.rvm/gems/ruby-1.9.3-p448@rails3tutorial2ndEd/gems/sqlite3-1.3.8/lib/sqlite3/database.rb:91:in `initialize'

包括踪迹

$ rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:migrate
== AddIndexToUsersEmail: migrating ===========================================
-- add_index(:users, :email, {:unique=>true})
rake aborted!
An error has occurred, this and all later migrations canceled:

如果我可以/应该提供更多信息,请告诉我?

谢谢

更多信息

$rake db:reset

-- create_table("attendees", {:force=>true})
-> 0.0120s
-- create_table("competitions", {:force=>true})
-> 0.0020s
-- create_table("devices", {:force=>true})
-> 0.0019s
-- create_table("users", {:force=>true})
-> 0.0045s
-- add_index("users", ["email"], {:name=>"index_users_on_email", :unique=>true})
-> 0.0011s
-- add_index("users", ["remember_token"], {:name=>"index_users_on_remember_token"})
-> 0.0010s
-- initialize_schema_migrations_table()
-> 0.0019s
-- assume_migrated_upto_version(20140210000927, ["/Users/Marcus/Sites/Rails/rails_projects/BattleOfTheBands/db/migrate"])
-> 0.0066s
You have 1 pending migrations:
20140211231110 AddDeviseToUsers
Run `rake db:migrate` to update your database then try again.

现在当我运行“rake db:migrate”时

SQLite3::SQLException: duplicate column name: email: ALTER TABLE "users" ADD "email" varchar(255) DEFAULT '' NOT NULL/Users/Marcus/.rvm/gems/ruby-1.9.3-p448@rails3tutorial2ndEd/gems/sqlite3-1.3.8/lib/sqlite3/database.rb:91:in `initialize'

最佳答案

在我的例子中,我能够通过删除我盒子上的 sqlite3 文件然后运行来解决这个问题:

    rake db:create

然后做:

    rake db:migrate

希望这对遇到同样问题的其他人有所帮助。

关于mysql - Rails - 没有这样的表 [rake db :migrate],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21716791/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com