[英]Table rails_project.users doesn't exist: SHOW FULL FIELDS FROM users
I have been trying to move my current rails application's db from sqlite to MYSQL. 我一直在尝试将当前的Rails应用程序的数据库从sqlite迁移到MYSQL。 I have made the changes in database.yml file. 我已经在database.yml文件中进行了更改。 But its been many times I ran rake:db create and migrate, but nothing does not work for me. 但是我运行rake:db创建并迁移了很多次,但是对我来说没有任何用处。
I end up in the error stating "Table 'rails_project.users' doesn't exist: SHOW FULL FIELDS FROM users
". 我最终遇到错误,指出“表'rails_project.users'不存在:从users
显示完整字段”。
My db name is rails_project and I am using devise authentication where the table name is users. 我的数据库名称是rails_project,并且我正在使用devise身份验证,其中表名称是users。
I am so frustrated with this issue. 我对此问题感到非常沮丧。
Can anyone help me? 谁能帮我?
database.yml: database.yml的:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: rails_project
pool: 5
username: root
password: root
host : localhost
socket: /var/run/mysqld/mysqld.sock
test:
adapter: mysql2
encoding: utf8
reconnect: false
database: rails_project
pool: 5
username: root
password: root
host : localhost
socket: /var/run/mysqld/mysqld.sock
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: rails_project
pool: 5
username: root
password: root
host : localhost
socket: /var/run/mysqld/mysqld.sock
migrated file: 迁移的文件:
class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table(:users) do |t|
## Database authenticatable
t.string :email, :null => false, :default => ""
t.string :encrypted_password, :null => false, :default => ""
This means that you are trying to use something before define its table, in my case I tried to use some code in factories.rb: 这意味着您在定义表之前尝试使用某些东西,在我的情况下,我尝试在factory.rb中使用一些代码:
Assesment.new.questions ...
So when I ran my code on travis during rake db:schema:load
all code is interpreted and in that part it got same error, solution is: 因此,当我在rake db:schema:load
期间在travis上运行代码时,所有代码都会被解释,并且在该部分中出现相同的错误,解决方案是:
Avoid using a model before define its table 避免在定义表之前使用模型
Use lazy syntax wrapping with {
and }
, at least in FactoryGirl use 至少在FactoryGirl中使用带有{
和}
惰性语法包装
Just tried to read carefully log to see was line of your code is triggering the error 只是想仔细阅读日志才能看到代码行触发了错误
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.