2 回答

TA貢獻(xiàn)1998條經(jīng)驗(yàn) 獲得超6個(gè)贊
將您的新表向上遷移方法更改為:
public function up()
{
//Create the table
Schema::create('your_table_name', function (Blueprint $table) {
$table->bigIncrements('id')->unique();
$table->bigInteger('client_log_id');
$table->mediumText('partition_data');
$table->timestamps();
});
//Copy column from last table to new table
foreach(MyOldModel::all() as $item)
{
//now you can save old data into new table old data : $item -> log_data
//other operation you want
MyNewModel::create(array('partition_data' => $item -> log_data));//you can save other columns with adding array values
}
//Drop old table column
Schema::table('client_logs', function (Blueprint $table) {
$table->dropColumn('log_data');
});
}
我認(rèn)為以這種方式也migrate:rollback命令應(yīng)該可以工作(用于撤消您的更改)!
- 2 回答
- 0 關(guān)注
- 198 瀏覽
添加回答
舉報(bào)