<?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('promotions', function (Blueprint $t) { $t->id(); $t->string('code', 255); $t->string('description', 255)->nullable(); $t->enum('status', ['active','inactive'])->default('active'); $t->integer('uses')->default(0); $t->integer('limit')->nullable(); $t->enum('type', ['percentage','fixed'])->default('percentage'); $t->decimal('amount', 8, 2); $t->unsignedBigInteger('currency_id')->nullable(); $t->integer('cycles')->nullable(); $t->date('start_date')->nullable(); $t->date('end_date')->nullable(); $t->integer('usage_limit_per_client')->nullable(); $t->boolean('is_combinable')->default(0); $t->json('applies_to')->nullable(); $t->json('requires_for')->nullable(); $t->boolean('only_new_client')->default(0); $t->boolean('only_existing_client')->default(0); $t->boolean('only_once_client')->default(0); $t->boolean('only_new_orders')->default(0); $t->boolean('allow_renewal')->default(0); $t->boolean('allow_upgrades')->default(0); $t->string('target_type', 255)->default('all'); $t->json('target_products')->nullable(); $t->json('target_groups')->nullable(); $t->timestamp('created_at')->nullable(); $t->timestamp('updated_at')->nullable(); $t->unique('code', 'promotions_code_unique'); $t->index('currency_id', 'promotions_currency_id_foreign'); $t->foreign('currency_id', 'promotions_currency_id_foreign')->references('id')->on('currencies')->onDelete('set null'); }); } public function down(): void { Schema::dropIfExists('promotions'); } }; 