32 lines
1.2 KiB
PHP
32 lines
1.2 KiB
PHP
<?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('buckets', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('scenario_id')->constrained()->onDelete('cascade');
|
|
$table->string('name');
|
|
$table->integer('priority')->comment('Lower number = higher priority, 1 = first');
|
|
$table->integer('sort_order')->default(0)->comment('For UI display ordering');
|
|
$table->enum('allocation_type', ['fixed_limit', 'percentage', 'unlimited']);
|
|
$table->decimal('allocation_value', 10, 2)->nullable()
|
|
->comment('Limit amount for fixed_limit, percentage for percentage type, NULL for unlimited');
|
|
$table->timestamps();
|
|
|
|
// Indexes for performance
|
|
$table->index(['scenario_id', 'priority']);
|
|
$table->unique(['scenario_id', 'priority'], 'unique_scenario_priority');
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('buckets');
|
|
}
|
|
};
|