laravel migration re-organising column order

后端 未结 4 899
再見小時候
再見小時候 2021-02-01 13:23

When you create a new column in a table you can use the ->after(\'column name\') to dictate where it goes. How can I create a migration that re-orders the columns in the right o

4条回答
  •  清歌不尽
    2021-02-01 14:02

    Try this, hope it help you to find right solution:

    public function up()
    {
    
        DB::statement("ALTER TABLE example MODIFY COLUMN foo DATE AFTER bar");
    
    }
    
    public function down()
    {
    
        DB::statement("ALTER TABLE example MODIFY COLUMN foo DATE AFTER bar");
    
    }
    

提交回复
热议问题