2013-02-18 33 views
5

मैं अपने उपयोगकर्ताओं तालिका के लिए एक नया माइग्रेशन बनाने के लिए कोशिश कर रहा हूँ, मैं निम्न स्कीमा है:Laravel 4 - कारीगर त्रुटि SQLSTATE [42000]

 Schema::create('users', function($t) { 
      $t->increments('id'); 
      $t->string('username', 16); 
      $t->string('password', 64); 
      $t->integer('role', 64); 
      $t->timestamps(); 
    }); 

जब मैं php कारीगर टर्मिनल से विस्थापित चलाने का प्रयास, मैं निम्नलिखित त्रुटि मिलती है:

[Exception]
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 users (id int unsigne d not null auto_increment primary key, username varchar(16) not null, password varchar(64) no t null, role int not null auto_increment primary key, created_at timestamp default 0 not null , updated_at timestamp default 0 not null)) (Bindings: array (
))

त्रुटि के रूप में जब इस निकाल दिया जाता है यह ठीक से चलाने के लिए लगता है, 'भूमिका' फ़ील्ड के साथ क्या करने के लिए कुछ नहीं है।

कोई मदद या जानकारी के लिए अग्रिम धन्यवाद।

+0

क्यों उत्पन्न एसक्यूएल सेट '' auto_increment प्राथमिक key' को role' करता है? 'Id' केवल 'auto_increment प्राथमिक कुंजी' कॉलम होने के साथ क्या गलत है? –

उत्तर

13

दूसरा पैरामीटर integer के लिए एक ऑटो वेतन वृद्धि झंडा है।

public function integer($column, $autoIncrement = false, $unsigned = false) 

https://github.com/laravel/framework/blob/5.4/src/Illuminate/Database/Schema/Blueprint.php#L510

+0

बढ़िया, मदद और संसाधन के लिए धन्यवाद :) चाल थी! – ChrisBratherton

+0

@TheRabbitFactory, मुझे पता है कि यह थोड़ी देर पहले है, लेकिन क्या आपको पता है कि मुझे क्या करना है, क्योंकि मुझे आपकी समस्या है क्योंकि – Thom

+0

मुझे वास्तव में याद नहीं है लेकिन मुझे लगता है कि मैं मूल रूप से उस दूसरे पैरामीटर को याद कर रहा था। – ChrisBratherton

0
$t->integer('role', false); 

कि यह ठीक करता है। पूर्णांक के

+3

क्या आप समझा सकते हैं कि यह क्यों ठीक करता है? –

+0

स्पष्टीकरण के बिना उत्तर का कोई उपयोग नहीं है। –

+0

गलत पर पूर्णांक निर्धारित करके मैं को निष्क्रिय AutoIncrement यही कारण है कि हम त्रुटि बायपास। –

0

लंबाई विशेषता यह permitted.Remove और कोशिश नहीं कर रहा है।

संबंधित मुद्दे