?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('order_items', function (Blueprint $table) { $table->id(); $table->foreignId('order_id')->constrained()->cascadeOnDelete()->index(); $table->foreignId('service_id')->nullable()->constrained()->nullOnDelete(); $table->string('name_snapshot'); $table->unsignedInteger('qty')->default(1); $table->decimal('unit_price', 12, 4)->default(0); $table->decimal('setup_fee', 12, 4)->default(0); $table->string('billing_model_snapshot')->default('recurring'); $table->json('config')->nullable(); $table->string('status')->default('pending')->index(); $table->timestamp('next_due_at')->nullable()->index(); $table->timestamps(); }); } public function down(): void { Schema::dropIfExists('order_items'); } };