<?php
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema;
return new class extends Migration {public function up():void{
 Schema::create('merchants',function(Blueprint $t){$t->id();$t->string('code',20)->unique();$t->string('name',120);$t->foreignId('country_id')->constrained('countries');$t->char('currency_code',3);$t->string('contact_name')->nullable();$t->string('contact_phone')->nullable();$t->string('contact_email')->nullable();$t->text('address')->nullable();$t->boolean('can_send')->default(false);$t->boolean('can_receive')->default(false);$t->unsignedBigInteger('per_txn_min_minor')->default(0);$t->unsignedBigInteger('per_txn_max_minor')->default(0);$t->unsignedBigInteger('daily_limit_minor')->default(0);$t->bigInteger('float_balance_minor')->default(0);$t->enum('status',['active','suspended','closed'])->default('active');$t->timestamps();$t->softDeletes();$t->foreign('currency_code')->references('code')->on('currencies');});
 Schema::table('users',fn(Blueprint $t)=>$t->foreign('merchant_id')->references('id')->on('merchants')->nullOnDelete());
 }public function down():void{Schema::table('users',fn(Blueprint $t)=>$t->dropForeign(['merchant_id']));Schema::dropIfExists('merchants');}};
