35 lines
1.2 KiB
PHP
35 lines
1.2 KiB
PHP
<?php
|
|
|
|
use App\Enums\BucketTypeEnum;
|
|
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->uuid()->unique();
|
|
$table->foreignId('scenario_id')->constrained()->onDelete('cascade');
|
|
$table->enum('type', BucketTypeEnum::values())->default(BucketTypeEnum::NEED->value);
|
|
$table->string('name');
|
|
$table->integer('priority');
|
|
$table->integer('sort_order')->default(0);
|
|
$table->enum('allocation_type', ['fixed_limit', 'percentage', 'unlimited']);
|
|
$table->unsignedBigInteger('allocation_value')->nullable();
|
|
$table->unsignedBigInteger('starting_amount')->default(0);
|
|
$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');
|
|
}
|
|
};
|