<?php

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Migrations\Migration;

/**
 * Graduate the Gynaecology specialty from a config-only row to a structural
 * one backed by this plugin's driver. Idempotent; safely no-ops if ClinicCore
 * isn't installed.
 */
class MakeGynaecologyStructural extends Migration
{
    public function up()
    {
        if (! Schema::hasTable('clc_specialties')) return;
        DB::table('clc_specialties')->whereNull('business_id')->where('code', 'gynaecology')
            ->update(['is_structural' => true, 'driver_key' => 'gynaecology', 'updated_at' => now()]);
    }

    public function down()
    {
        if (! Schema::hasTable('clc_specialties')) return;
        DB::table('clc_specialties')->whereNull('business_id')->where('code', 'gynaecology')
            ->update(['is_structural' => false, 'driver_key' => null, 'updated_at' => now()]);
    }
}
