0

when i am migrating i got this error one more thing there is two migrate file for users table one for create and other for alter it the below code id for alter table . Because of it i can't further migrate table's , also if possible please provide me any link of tuts. for migration

this is my migration code and it's for alter the table

    public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->integer('active')->after('id')->unsigned()->nullable();
            $table->integer('status')->after('active')->unsigned()->nullable();
            $table->string('sysid')->after('status')->nullable();
            $table->string('workarea', 200)->after('sysid')->nullable();
            $table->string('first', 50)->after('name');
            $table->string('last', 50)->after('first');
            $table->text('bio')->nullable()->after('last');
            $table->string('cover_image', 50)->nullable()->after('bio');
            $table->json('score')->nullable()->after('cover_image');
            $table->integer('language_id')->nullable()->unsigned();
            $table->integer('company_id')->nullable()->unsigned();
            $table->integer('team_id')->nullable()->unsigned();
//            $table->json('avatar')->nullable();
            $table->text('avatar')->nullable();
            $table->foreign('language_id')->references('id')->on('languages');
            $table->foreign('company_id')->references('id')->on('companies');
            $table->foreign('team_id')->references('id')->on('teams');

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('users', function (Blueprint $table) {

            $table->dropForeign('users_language_id_foreign');
            $table->dropForeign('users_company_id_foreign');
            $table->dropForeign('users_team_id_foreign');

            $table->dropColumn('active');
            $table->dropColumn('status');
            $table->dropColumn('language_id');
            $table->dropColumn('company_id');
            $table->dropColumn('team_id');
            $table->dropColumn('first');
            $table->dropColumn('last');
            $table->dropColumn('bio');
            $table->dropColumn('cover_image');
            $table->dropColumn('score');

        });

    }

the error is near cover_image don't know what i doing wrong thanks in advance

1 Answers1

0

your error is in this line

 $table->json('score')->nullable()->after('cover_image');

change your datatype it will work fine like this if you want it as integer

  public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->integer('active')->after('id')->unsigned()->nullable();
            $table->integer('status')->after('active')->unsigned()->nullable();
            $table->string('sysid')->after('status')->nullable();
            $table->string('workarea', 200)->after('sysid')->nullable();
            $table->string('first', 50)->after('name');
            $table->string('last', 50)->after('first');
            $table->text('bio')->nullable()->after('last');
            $table->string('cover_image', 50)->nullable()->after('bio');
            $table->integer('score')->nullable()->after('cover_image');
            $table->integer('language_id')->nullable()->unsigned();
            $table->integer('company_id')->nullable()->unsigned();
            $table->integer('team_id')->nullable()->unsigned();
//            $table->json('avatar')->nullable();
            $table->text('avatar')->nullable();
            $table->foreign('language_id')->references('id')->on('languages');
            $table->foreign('company_id')->references('id')->on('companies');
            $table->foreign('team_id')->references('id')->on('teams');

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('users', function (Blueprint $table) {

            $table->dropForeign('users_language_id_foreign');
            $table->dropForeign('users_company_id_foreign');
            $table->dropForeign('users_team_id_foreign');

            $table->dropColumn('active');
            $table->dropColumn('status');
            $table->dropColumn('language_id');
            $table->dropColumn('company_id');
            $table->dropColumn('team_id');
            $table->dropColumn('first');
            $table->dropColumn('last');
            $table->dropColumn('bio');
            $table->dropColumn('cover_image');
            $table->dropColumn('score');

        });

    }

think it will work for you

Gaurav Gupta
  • 1,588
  • 2
  • 14
  • 21