How can I change the default primary key in Laravel?
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddSubcategorias extends Migration
{
public function up()
{
Schema::create('categorias', function (Blueprint $table) {
$table->primary(array('acronimo_categorias', 3));
$table->string('descripcion', 50);
$table->string('registro_calidad' ,1);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('categorias');
}
}
In the laravel documentation it says that putting primary should also work and I tested it this way:
$table->primary('acronimo_categorias,', 3);
But it doesn't work either, I use laravel 5.2
The correct way according to the Laravel syntax would be something like this, first you define the field and then mark it as primary index: