Laravelでmigrateしてもphpmyadminにテーブルが作られません。
この事態が発生した流れを書きます。
phpmyadminでmybbsデータベースを作っておく(中身は空)
↓
artisanコマンドでmigrationファイルを作成
php artisan make:model Article -m -c -r
articleコントローラーが作られる
↓
migrationファイルは3つ
・2014_10_12_0000_create_users_table.php
・2014_10_12_0000_create_password_resets_table.php
・2019_04_08_0804_create_articles_table.php
↓
articleコントローラーの内容を以下に変更
public function up() { Schema::create('articles', function (Blueprint $table) { // id情報 $table->increments('id'); // 文字なのでストリングで指定 $table->string('content'); // 日時記録 $table->timestamps(); }); }
↓
以下のコマンドを実行
php artisan migrate
↓
エラー発生(内容は後述)
↓
phpmyadminで作っておいたmybbsデータベースに
・migrations
・users
この2つのテーブルしか作られない
・password_resets
・articles
が作成されない
エラー内容
Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`)) at C:\xampp\htdocs\bbs\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664 660| // If an exception occurs when attempting to run a query, we'll format the error 661| // message to include the bindings with SQL, which will make this exception a 662| // lot more helpful to the developer instead of just the database's errors. 663| catch (Exception $e) { > 664| throw new QueryException( 665| $query, $this->prepareBindings($bindings), $e 666| ); 667| } 668| Exception trace: 1 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes") C:\xampp\htdocs\bbs\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458 2 PDOStatement::execute() C:\xampp\htdocs\bbs\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458 Please use the argument -v to see more details.
エラー文を読んでみたところ、『指定されたキーが長すぎる』というような内容かと思ったのですが、何が長すぎるのか見当もつきません。
参考になりそうな情報も見つかりませんでした。
何が原因でテーブルが作成されないのでしょうか。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/04/09 01:12
2019/04/09 04:34 編集
2019/04/09 07:29