0

I want to create a login/register window. now I wanted to create my database tables. Then comes the following message:

Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table

   Illuminate\Database\QueryException 

  SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'migration' at row 1 (SQL: insert into `migrations` (`migration`, `batch`) values (2014_10_12_000000_create_users_table, 1))

User Table:

<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->string('vertification_code')->nullable();
            $table->integer('is_verified')->default(0);
            $table->rememberToken();
            $table->timestamps();
        });
    }

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

I found out that I can change the "string" to a "text" and then it can work(https://laracasts.com/discuss/channels/laravel/string-data-right-truncated-1406-error). But my problem is that I can't change anything in the table "migration" because as far as I know it is created automatically by laravel.

3
  • Yes this migration comes with laravel but you can update that column, in your database/migraitons/themigrationyouwanttochange Commented Mar 10, 2022 at 8:01
  • Which column ? I did consider the problem column @MuhammadShareyar Commented Mar 10, 2022 at 8:05
  • migration column as it is mentioned update the data is too long for column migration Commented Mar 10, 2022 at 8:07

1 Answer 1

2

You could try to edit your app/providers.php to below codes.

use Illuminate\Support\Facades\Schema;

public function boot()
{
    Schema::defaultStringLength(191);
}

It will make all of string that migration used use 191 as the default length.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.