2015-05-19 6 views
6

मैं एक तरह उसके डिफ़ॉल्ट पूर्णांक मान के रूप कोड लग होने एक तालिका बनाने के लिए कोशिश कर रहा था:Laravel 5 प्रवासन, अवैध डिफ़ॉल्ट मूल्य जब पूर्णांक

Schema::create('gsd_proyecto', function($table) { 
     $table->increments('id'); 
     $table->string('nombre', 80)->unique(); 
     $table->string('descripcion', 250)->nullable(); 
     $table->date('fechaInicio')->nullable(); 
     $table->date('fechaFin')->nullable(); 
     $table->integer('estado', 1)->default(0); 
     $table->string('ultimoModifico', 35)->nullable(); 
     $table->timestamps(); 
    }); 

लेकिन मैं जब मैं माइग्रेशन चला मीटर अगले त्रुटि मिल रही है:

Next exception 'Illuminate\Database\QueryException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'estado' 

मैं जाँच की गई थी laravel द्वारा बनाई एसक्यूएल है और मैं अगले

create table `gsd_proyecto` (
`id` int unsigned not null auto_increment primary key, 
`nombre` varchar(80) not null, 
`descripcion` varchar(250) null, 
`fechaInicio` date null, 
`fechaFin` date null, 
`estado` int not null default '0' auto_increment primary key, 
`ultimoModifico` varchar(35) null, 
`created_at` timestamp default 0 not null, 
`updated_at` timestamp default 0 not null 
) 
पाया क्या

आप देख सकते हैं, laravel एक चार मूल्य के साथ मैदान Estado स्थापित करने के लिए ('0') और के रूप में भी एक autoincrement प्राथमिक कुंजी

किसी भी मदद वास्तव में सराहना की जाएगी

उत्तर

12

कोशिश कर रहा है integer विधि में दूसरे पैरामीटर को हटा दें। यह कॉलम को स्वत: वृद्धि के रूप में सेट करता है। अधिक detials के लिए Laravel एपीआई की जांच करें।

http://laravel.com/api/5.0/Illuminate/Database/Schema/Blueprint.html#method_integer

$table->integer('estado')->default(0); 
+2

यह काम किया! आपका बहुत बहुत धन्यवाद! मैं माईस्क्ल की तरह परिभाषा में सोच रहा था .... इसके बजाय मैं अब छोटे इंटेगर का उपयोग कर रहा हूं और अब यह काम कर रहा है। आपका बहुत बहुत धन्यवाद! – WindSaber

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