doubihuai8468 2018-02-14 08:04
浏览 143
已采纳

如何在迁移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?

  • 写回答

1条回答 默认 最新

  • douke9379 2018-02-14 08:11
    关注

    Change the same and try this way... hope it will work.

    $table->enum('event_info', ['sync', 'start_event', 'end_end', 'start_meeting_session', 'last_track_time']);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 模电中二极管,三极管和电容的应用
  • ¥15 关于模型导入UNITY的.FBX: Check external application preferences.警告。
  • ¥15 气象网格数据与卫星轨道数据如何匹配
  • ¥100 java ee ssm项目 悬赏,感兴趣直接联系我
  • ¥15 微软账户问题不小心注销了好像
  • ¥15 x264库中预测模式字IPM、运动向量差MVD、量化后的DCT系数的位置
  • ¥15 curl 命令调用正常,程序调用报 java.net.ConnectException: connection refused
  • ¥20 关于web前端如何播放二次加密m3u8视频的问题
  • ¥15 使用百度地图api 位置函数报错?
  • ¥15 metamask如何添加TRON自定义网络