<?php

use App\OrderIssue;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class SyncOrderIssueUserWorkgroup extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $orderIssues = OrderIssue::query()->whereNotNull('user_workgroup_id')->get();
        foreach ($orderIssues as $orderIssue) {
            $orderIssue->userWorkgroups()->attach($orderIssue->user_workgroup_id);
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}
