buckets/database/migrations/2025_12_29_205724_create_buckets_table.php

36 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2025-12-29 23:32:05 +01:00
<?php
use App\Enums\BucketTypeEnum;
2025-12-29 23:32:05 +01:00
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();
2025-12-29 23:32:05 +01:00
$table->foreignId('scenario_id')->constrained()->onDelete('cascade');
$table->enum('type', BucketTypeEnum::values())->default(BucketTypeEnum::NEED->value);
2025-12-29 23:32:05 +01:00
$table->string('name');
$table->integer('priority');
$table->integer('sort_order')->default(0);
2025-12-29 23:32:05 +01:00
$table->enum('allocation_type', ['fixed_limit', 'percentage', 'unlimited']);
$table->unsignedBigInteger('allocation_value')->nullable();
$table->unsignedBigInteger('starting_amount')->default(0);
2025-12-29 23:32:05 +01:00
$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');
}
};