Hello, I'm running some tests in my application, but I'm having the following problem: After migrate
and db:seed
, whenever I'm going to insert some registry by applying a duplicate primary key error. I have already seen that this error is due to increment
continuing in 1 even after inserting data with db:seed
. Is there any way I can set this value manually automatically, without having to go from table to table and changing?
Seed:
public function run()
{
Model::unguard();
App\Models\Admin\Profissao::create(['id' => '1',
'titulo' => 'Engenheiro(a)',
]);
App\Models\Admin\Profissao::create(['id' => '2',
'titulo' => 'Tecnólogo(a)',
]);
Model::reguard();
}
Migration:
public function up()
{
Schema::create('profissoes', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('titulo', 16);
$table->longText('descricao')->nullable();
$table->timestamps();
});
}