gpt4 book ai didi

php - 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

转载 作者:行者123 更新时间:2023-11-29 03:50:32 38 4
gpt4 key购买 nike

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]: 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)

还有这个

[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

最佳答案

根据我的观察,我会说您应该删除添加到外部字段的 default 值(例如):

$table->integer('thnajrn_id', 10)->unsigned(); 

收件人:

$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.*

希望这有帮助:)

关于php - 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,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42053392/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com