简体   繁体   English

表rails_project.users不存在:显示用户的完整字段

[英]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.

相关问题 rails db:migrate failed&#39;[MODEL] .users&#39;不存在:显示来自`users`的完整字段 - rails db:migrate fails '[MODEL].users' doesn't exist: SHOW FULL FIELDS FROM `users` 表&#39;project_dev.users&#39;不存在 - Table 'project_dev.users' doesn't exist Mysql2 ::错误:表不存在:显示来自`sessions`的完整字段 - Mysql2::Error: Table doesn't exist: SHOW FULL FIELDS FROM `sessions` Mysql2::Error: 表 &#39;table_name&#39; 不存在:显示来自 `table_name` 的完整字段 - Mysql2::Error: Table 'table_name' doesn't exist: SHOW FULL FIELDS FROM `table_name` rake db:migrate-Mysql2 :: Error:表&#39;database_development.locations&#39;不存在:从`locations&#39;中显示完整字段 - rake db:migrate - Mysql2::Error: Table 'database_development.locations' doesn't exist: SHOW FULL FIELDS FROM `locations` Rails控制台:项目(表不存在?)-SQLite3 - Rails Console: Project(Table doesn't exist?) - Sqlite3 在Rails项目中的Users#show中NoMethodError - NoMethodError in Users#show on rails project 来自控制台的Ruby on rails - (表不存在) - Ruby on rails from console - (Table doesn't exist) Mysql2::Error: 表 &#39;my_database.users&#39; 不存在 - Mysql2::Error: Table 'my_database.users' doesn't exist 即使控制器中没有定义“show”方法,Rails 5 get users_path(10) 测试也不会失败 - Rails 5 get users_path(10) test doesn't fail even no "show" method defined in controller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM