My Problem
I'm building my first api using laravel and am getting a multiple primary key defined error while trying to run php artisan migrate
I don't understand how I have defined multiple primary keys. Every time I run a migrate I get these errors php artisan migrate error.
My Troubleshooting
I thought since autoIncrementing() can only be used for a primary key that maybe that defined it as a primary key, so I altered $table->increments('bus_id')->autoIncrement()->primary();
to $table->increments('bus_id')->autoIncrement();
and $table->increments('bus_id')->autoIncrement();
Every time I had tried to run my migrations I dropped my database and re-created it and tried to run my migrations again (so it was a new database every time with no corrupt data) but still didn't make a difference.
I checked my Connection.php that was mentioned in the picture of my error code above but didn't see anything pertaining to any primary keys.
My Question
My code is below, can someone help me understand how I'm making double primary keys?
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateBusinessTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('business', function (Blueprint $table) {
$table->increments('bus_id')->autoIncrement()->primary();
$table->string('bus_name');
$table->string('bus_address');
$table->string('bus_city');
$table->string('bus_prov');
$table->string('bus_postal');
$table->string('bus_phone');
$table->string('bus_email');
$table->string('bus_password');
$table->double('max_donatable', 10, 2);
$table->integer('cashback_percent');
$table->binary('bus_cover_photo');
$table->binary('bus_profile_pic');
$table->timestamps();
$table->rememberToken();
$table->engine = 'InnoDB';
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('business');
}
}
Please note there are similar questions here on Stack overflow which I have also tried their solutions without any success
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2FwT1ru
via IFTTT
Aucun commentaire:
Enregistrer un commentaire