public function up()
{
Schema::create('jadwal_praks', function (Blueprint $table) {
$table->increments('id');
$table->integer('thnajrn_id', 10)->unsigned();
$table->foreign('thnajrn_id')->references('id')->on('tahun_ajarans');
$table->integer('prak_id', 10)->unsigned();
$table->foreign('prak_id')->references('Prak_kode')->on('mata_praks');
$table->integer('hari_id', 10)->unsigned();
$table->foreign('hari_id')->references('id')->on('haris');
$table->integer('jam_id', 10)->unsigned();
$table->foreign('jam_id')->references('id')->on('jams');
$table->integer('ruang_id', 10)->unsigned();
$table->foreign('ruang_id')->references('id')->on('ruangs');
$table->integer('kap_id', 10)->unsigned();
$table->foreign('kap_id')->references('id')->on('kapasitas');
$table->timestamps();
$table->rememberToken();
});
}
After run php artisan migrate
[Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto co lumn and it must be defined as a key (SQL: create table
jadwal_praks
(id
int unsigned not null auto_increment
primary key,thnajrn_id
int unsigned not null auto_increment primary key,prak_id
int unsigned not null auto _increment primary key,hari_id
int unsigned not null auto_increment primary key,jam_id
int unsigned not nul l auto_increment primary key,ruang_id
int unsigned not null auto_increment primary key,kap_id
int unsigned
not null auto_increment primary key,created_at
timestamp null,updated_at
timestamp null,remember_token
v archar(100) null) default character set utf8 collate utf8_unicode_ci)
And this
[PDOException] 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
With my observation, I would say you should remove default
value you added to the your foreign fields from (for example):
$table->integer('thnajrn_id', 10)->unsigned();
To:
$table->integer('thnajrn_id')->unsigned();
PS: With a similar experience, I know presently this works with one of the projects I work with in Laravel 5.2.*
Hope this helps :)
When you use $table->integer('thnajrn_id', 10)->unsigned()
; this means your setting the second parameter as true which represents AutoIncrement
try
table->integer('thnajrn_id')->length(10)->unsigned();
More info
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With