jeudi 16 juin 2016

how to change datatype from string to autoincrement in Laravel?

I have following schema for my migration:

 Schema::create('client', function(Blueprint $table)
    {
        $table->increments('id');

        $table->string('nbr', 10)->nullable()->default(null);
        $table->string('name', 100);
        $table->string('search', 100);
        $table->string('image', 100)->nullable()->default(null);
    }

I am trying to change string 'nbr' to autoincrements. I have tried several solutions but none of them works.I have tried followings:

 Schema::table('client', function(Blueprint $table)
    {
       // $table->increments('nbr')->change();
        //$table->dropPrimary('nbr');
       DB::statement('ALTER TABLE client ALTER COLUMN nbr TYPE Integer NOT NULL AUTO_INCREMENT;');
    });

NOTE: i am using postgresql



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire