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();
});
}
运行后 php artisan migrate
[Illuminate\Database\QueryException] SQLSTATE[42000]:语法错误或访问冲突:1075 表定义不正确;只能有一个自动列,它必须被定义为一个键(SQL: create table
jadwal_praks
(id
int unsigned not null auto_incrementprimary 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 null l auto_increment 主键,ruang_id
int unsigned not null auto_increment 主键,kap_id
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)
和这个
[PDOException] SQLSTATE[42000]:语法错误或访问冲突:1075 表定义不正确;只能有一个自动列,并且必须将其定义为键
原文由 Muhammad Adnan Syarief 发布,翻译遵循 CC BY-SA 4.0 许可协议
根据我的观察,我会说你应该删除
default
你添加到你的外部字段的值来自(例如):到:
希望这可以帮助 :)