laravel數(shù)據(jù)庫(kù)遷移中integer類(lèi)型是無(wú)法指定長(zhǎng)度的,很多小伙伴對(duì)integer類(lèi)型傳遞第二個(gè)參數(shù)后會(huì)發(fā)現(xiàn)遷移報(bào)以下錯(cuò)誤
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代碼后發(fā)現(xiàn)通過(guò)integer指定長(zhǎng)度創(chuàng)建的子段自動(dòng)添加了auto increament 以及 primary key 屬性
int not null auto_increment primary key
查看源代碼后發(fā)現(xiàn)integer方法的第二個(gè)參數(shù)并不是指定長(zhǎng)度,而是是否設(shè)置auto increment,所以integer方法無(wú)法指定子段長(zhǎng)度,默認(rèn)為11。
public function integer($column, $autoIncrement = false, $unsigned = false) { return $this->addColumn('integer', $column, compact('autoIncrement', 'unsigned')); }
以上這篇關(guān)于laravel 數(shù)據(jù)庫(kù)遷移中integer類(lèi)型是無(wú)法指定長(zhǎng)度的問(wèn)題就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
標(biāo)簽:烏魯木齊 山南 赤峰 三亞 南寧 濟(jì)寧 鷹潭 迪慶
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《關(guān)于laravel 數(shù)據(jù)庫(kù)遷移中integer類(lèi)型是無(wú)法指定長(zhǎng)度的問(wèn)題》,本文關(guān)鍵詞 關(guān)于,laravel,數(shù)據(jù)庫(kù),遷移,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。