0
以下遷移功能:Laravel遷移腳本產生多個主鍵列
public function up()
{
Schema::create('translations', function (Blueprint $table) {
$table->increments('id');
$table->string('table_name', 32);
$table->string('column_name', 32);
$table->integer('foreign_key', 11)->unsigned();
$table->string('locale', 11);
$table->text('value');
$table->unique(['table_name', 'column_name', 'foreign_key', 'locale']);
$table->timestamps();
});
}
是生產以下SQL查詢:
create table `translations` (
`id` int unsigned not null auto_increment primary key,
`table_name` varchar(32) not null,
`column_name` varchar(32) not null,
`foreign_key` int unsigned not null auto_increment primary key,
`locale` varchar(11) not null,
`value` text not null,
`created_at` timestamp null,
`updated_at` timestamp null
) default character set utf8mb4 collate utf8mb4_unicode_ci engine = InnoDB ROW_FORMAT=DYNAMIC
通知在foreign_key
字段附加auto_increment primary key
。這就是問題。如何更改遷移腳本,使其不會使第二個auto_increment primary key
列成爲foreign_key
列?
(在情況下,這看起來很熟悉,這是來自於Voyager基本代碼。)