我想用这段代码创建一个表。如何使自动增量列非自动增量?
public function up()
{
Schema::create('BookInfo', function (Blueprint $table) {
$table->increments('id');
$table->integer('bookId',11);
$table->string('Name',255);
$table->string('Publisher')->nullable();
$table->integer('Publishing_year',4)->nullable();
$table->integer('Price',5)->nullable();
$table->string('Language',30);
$table->timestamps();
});
}
当我试着php artisan migrate
它显示我这个错误。
[Illuminate\Database\QueryException]
的BookInfo
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(
BOOKIDint not null auto_increment primary key,
名称varchar(255) not null,
出版商varchar(255) null,
Publishing_yearint null auto_increment primary key,
价格int null auto_increment primary key,
语言varchar(30) not null,
created_attimestamp default 0 not null,
的updated_attimestamp default 0 not 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
看来laravel通吃整列,自动递增。这里发生了什么事实,而且t会是解决方案吗?