LoginSignup
0
0

More than 1 year has passed since last update.

SQLite3::SQLException: no such table: users: 〜のエラー解決方法

Posted at

私が解決に苦戦したエラーを記載します。

エラーメッセージ

SQLite3::SQLException: no such table: users: ALTER TABLE "users" ADD "email" varchar DEFAULT '' NOT NULL

マイグレーションファイル
2020**********_devise_create_users.rb
class DeviseCreateUsers < ActiveRecord::Migration[6.1]
  def change
    change_table :users do |t|

      t.string :email,              null: false, default: ""
      t.string :encrypted_password, null: false, default: ""

      以下略

解決策

エラー文にno such tableとあり、テーブルがないことを指摘されています。
したがって、テーブルを作成してあげれば解決できます。

方法は以下の通りです。

change_table :users do |t|create_table :users do |t|に変更する

マイグレーションファイル
2020**********_devise_create_users.rb
class DeviseCreateUsers < ActiveRecord::Migration[6.1]
  def change
    create_table :users do |t|

      t.string :email,              null: false, default: ""
      t.string :encrypted_password, null: false, default: ""

      以下略

これだけで解決したのですが、「usersテーブルは作ったはず」と思い込み、
この解決策にたどり着くのに時間がかかりました。

もし同じようなエラーが出ましたら試してみてください!

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0