mercredi 14 février 2018

How to set lenght for enum type in migration Laravel 5

I have a migration for MySQL:

 class MakeEventsTable extends Migration
    {
        /**
         * Run the migrations.
         *
         * @return void
         */
        public function up()
        {
            Schema::create('events', function (Blueprint $table) {
                $table->increments('id');
                $table->enum('type', ['sync', 'start_event', 'end_end', 'start_meeting_session', 'last_track_time'])->;
                $table->timestamp('created_at');
            });
        }
}

As a result, I have an error:

"SQLSTATE[01000]: Warning: 1265 Data truncated for column 'type' at row 1 (SQL: insert into `events` (`item_id`, `item_type`, `type`, `created_at`) values (45, meeting, last_track_time, 2018-02-14 06:52:10))"

This is because field type too small, and I am finding out a solution, how to increase the length of the field?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire