Merge pull request #3750 from devansh-webkul/migration_issue

Migration Issue Fixed
This commit is contained in:
Jitendra Singh 2020-08-13 17:21:07 +05:30 committed by GitHub
commit 3247c5ad4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 19 deletions

View File

@ -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]);
});
});
}