前提・実現したいこと
お世話になります。
Laravelでmigrationを試みたところ、下記のエラーが発生しました。
現象としては、マイグレーションはされるものの、10近くあるテーブルのうち、上から二つ目のtransacationテーブルまでしかテーブルが作られず、また、transacationテーブルのカラムに’transacation_id'が存在せず、代わりに'way'がAUTO_INCREMENTとなっています。
主キーが原因かと思い、$table->primary()で指定したり、->unsigned(); を付けてみたり、idの名前を'transacation-id'から'id'に変更したりと、色々試しましたが、どれも上手くいきませんでした。
ご助力お願いいたします。
発生している問題・エラーメッセージ
In Connection.php line 664: SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key (SQL: create table `transa ctions` (`transacation-id` int unsigned not null auto_increment primary key, `user-id` int not null, `item_id` int null, `way` int not null auto_increment primary key, `fluctua tion_point` int not null, `total_point` int not null, `created_at` datetime null, `updated_at` datetime null) default character set utf8mb4 collate utf8mb4_unicode_ci)
In Connection.php line 458: SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key
該当のソースコード
php
1<?php 2 3use Illuminate\Support\Facades\Schema; 4use Illuminate\Database\Schema\Blueprint; 5use Illuminate\Database\Migrations\Migration; 6 7class CreateTransactionsTable extends Migration 8{ 9 /** 10 * Run the migrations. 11 * 12 * @return void 13 */ 14 15 public function up() 16 { 17 Schema::create('transactions', function (Blueprint $table) { 18 $table->increments('transacation-id')->unsigned(); 19 $table->integer('user-id'); 20 $table->integer('item_id')->nullable(); 21 $table->integer('way', 3); 22 $table->integer('fluctuation_point'); 23 $table->integer('total_point'); 24 $table->dateTime('created_at')->nullable(); 25 $table->dateTime('updated_at')->nullable(); 26 }); 27 } 28 /** 29 * Reverse the migrations. 30 * 31 * @return void 32 */ 33 public function down() 34 { 35 Schema::dropIfExists('transactions'); 36 } 37} 38
補足情報(FW/ツールのバージョンなど)
larval (v5.5.28)
PHP(7.1)
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/27 05:23