doupa1883 2017-07-07 01:26
浏览 118

在laravel中将旧表迁移到新表

I have a problem where i need to migrate old table to new table. The old table data example like this:

Old table(Leave table)

Id   User_id    Reason    Date
1    100          Fever      29/01/2013
2    100          Fever      30/01/2013
3    100          Fever      31/01/2013
4    100          Fever      01/02/2013

New table(Leave table)

Id   User_id    Reason    Start Date   End Date
1    100          Fever      29/01/2013   01/02/2013


Is there any way where i can iterate old table and store like new table.?

29/01/2013 - 01/02/2013 produce 4 rows.. new table need 1 rows which start date and end date which 29/01/2013 be the start date and 01/02/2013 be the end date

new table i already created. i just want to iterate the list of old table and insert it into new table which have start date and end date.

  • 写回答

2条回答 默认 最新

  • dongpiansui8755 2017-07-07 01:55
    关注

    You can rename the Date column to Start Date and add a new column End Date like this,

    Schema::table('users', function($table)
    {
        $table->renameColumn('Date', 'Start Date');
        $table->dateTime('End Date');
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置