1

I just deployed my laravel app to heroku. I am using clearDB as MySQL database. The problem is that my migration files work perfectly locally. But when i try to migrate to clearDB database, instead of auto incrementing my primary keys, it just concatenates the first number 1.

For example instead of incrementing to 1, 2, 3, 4,; it does 1, 11, 111, 1111

This is my migration file

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateRolesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('roles', function (Blueprint $table) {
            $table->tinyIncrements('id');
            $table->string('name');
            $table->string('full_name');
            $table->text('description')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('roles');
    }
}

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->unsignedTinyInteger('role_id')->nullable();
            $table->foreign('role_id')->references('id')->on('roles');
            $table->string('first_name');
            $table->string('last_name');
            $table->string('username')->nullable();
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->boolean('active')->default(true);
            $table->rememberToken();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}

Precious Aang
  • 53
  • 1
  • 4
  • 12
  • are you sure it does 111, does it do 21, 31, ... 91, 101 before 111? Code should never depend on anything beyond a unique number from an auto-increment field – danblack May 26 '20 at 01:51
  • Yeah you're right it increases by 10. Thanks a lot. I just had reconfigure my inserts. – Precious Aang May 26 '20 at 02:19

0 Answers0