前提・実現したいこと
ここに質問の内容を詳しく書いてください。
railsのdeviseでユーザー管理機能をしているのですが、maigrateができません。
ターミナルで以下のメッセージがでます
発生している問題・エラーメッセージ
rails aborted! ActiveRecord::NoDatabaseError: Unknown database 'photzoo_35_development' /Users/nakamatsumayumi/projects/photzoo-35/bin/rails:9:in `<top (required)>' /Users/nakamatsumayumi/projects/photzoo-35/bin/spring:15:in `<top (required)>' bin/rails:3:in `load' bin/rails:3:in `<main>' Caused by: Mysql2::Error: Unknown database 'photzoo_35_development' /Users/nakamatsumayumi/projects/photzoo-35/bin/rails:9:in `<top (required)>' /Users/nakamatsumayumi/projects/photzoo-35/bin/spring:15:in `<top (required)>' bin/rails:3:in `load' bin/rails:3:in `<main>' Tasks: TOP => db:migrate (See full trace by running task with --trace) nakamatsumayumi@nakamatuminoMBP photzoo-35 %
該当のソースコード
マイグレーションファイル
class DeviseCreateUsers < ActiveRecord::Migration[6.0] def change create_table :users do |t| ## Database authenticatable t.string :email, null: false, default: "" t.string :encrypted_password, null: false, default: "" t.nickname :string, null: false t.family_name :string, null: false t.fist_name :string, null: false t.family_name_kana :string, null: false t.fist_name_kana :string, null: false t.birthdata :data, null: false ## Recoverable t.string :reset_password_token t.datetime :reset_password_sent_at ## Rememberable t.datetime :remember_created_at ## Trackable # t.integer :sign_in_count, default: 0, null: false # t.datetime :current_sign_in_at # t.datetime :last_sign_in_at # t.string :current_sign_in_ip # t.string :last_sign_in_ip ## Confirmable # t.string :confirmation_token # t.datetime :confirmed_at # t.datetime :confirmation_sent_at # t.string :unconfirmed_email # Only if using reconfirmable ## Lockable # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts # t.string :unlock_token # Only if unlock strategy is :email or :both # t.datetime :locked_at t.timestamps null: false end add_index :users, :email, unique: true add_index :users, :reset_password_token, unique: true # add_index :users, :confirmation_token, unique: true # add_index :users, :unlock_token, unique: true end end
database.yml
# MySQL. Versions 5.5.8 and up are supported. # # Install the MySQL driver # gem install mysql2 # # Ensure the MySQL gem is defined in your Gemfile # gem 'mysql2' # # And be sure to use new-style password hashing: # https://dev.mysql.com/doc/refman/5.7/en/password-hashing.html # default: &default adapter: mysql2 encoding: utf8 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: root password: socket: /tmp/mysql.sock development: <<: *default database: photzoo_35_development # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: <<: *default database: photzoo_35_test # As with config/credentials.yml, you never want to store sensitive information, # like your database password, in your source code. If your source code is # ever seen by anyone, they now have access to your database. # # Instead, provide the password as a unix environment variable when you boot # the app. Read https://guides.rubyonrails.org/configuring.html#configuring-a-database # for a full rundown on how to provide these environment variables in a # production deployment. # # On Heroku and other platform providers, you may have a full connection URL # available as an environment variable. For example: # # DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase" # # You can use this database configuration with: # # production: # url: <%= ENV['DATABASE_URL'] %> # production: <<: *default database: photzoo_35_production username: photzoo_35 password: <%= ENV['PHOTZOO_35_DATABASE_PASSWORD'] %>
試したこと
マイグレーションファイルがおかしい?と思い見直しみましたがわからない
すいません。
何かアドバイスをおねがいします。
補足情報(FW/ツールのバージョンなど)
Ruby on rails 6
devise
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。