Merge pull request #3750 from devansh-webkul/migration_issue
Migration Issue Fixed
This commit is contained in:
commit
3247c5ad4e
|
|
@ -1,8 +1,5 @@
|
|||
<?php
|
||||
|
||||
use Webkul\Sales\Models\Invoice;
|
||||
use Webkul\Sales\Models\Shipment;
|
||||
use Webkul\Sales\Models\OrderAddress;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
|
@ -18,26 +15,10 @@ class RemovingForiegnKey extends Migration
|
|||
{
|
||||
Schema::table('invoices', static function (Blueprint $table) {
|
||||
$table->dropForeign(['order_address_id']);
|
||||
|
||||
OrderAddress::query()
|
||||
->orderBy('id', 'asc') // for some reason each() needs an orderBy in before
|
||||
->each(static function ($row) {
|
||||
Invoice::query()
|
||||
->where('order_address_id', $row->additional['old_order_address_id'])
|
||||
->update(['order_address_id' => $row->id]);
|
||||
});
|
||||
});
|
||||
|
||||
Schema::table('shipments', static function (Blueprint $table) {
|
||||
$table->dropForeign(['order_address_id']);
|
||||
|
||||
OrderAddress::query()
|
||||
->orderBy('id', 'asc') // for some reason each() needs an orderBy in before
|
||||
->each(static function ($row) {
|
||||
Shipment::query()
|
||||
->where('order_address_id', $row->additional['old_order_address_id'])
|
||||
->update(['order_address_id' => $row->id]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue