Files
usher-manage-stack/database/migrations/2025_11_19_133732_create_budgets_table.php
2025-11-20 23:21:05 +08:00

41 lines
1.5 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('budgets', function (Blueprint $table) {
$table->id();
$table->integer('fiscal_year')->comment('Fiscal year (e.g., 2025)');
$table->string('name')->comment('Budget name');
$table->enum('period_type', ['annual', 'quarterly', 'monthly'])->default('annual')->comment('Budget period type');
$table->date('period_start')->comment('Period start date');
$table->date('period_end')->comment('Period end date');
$table->enum('status', ['draft', 'submitted', 'approved', 'active', 'closed'])->default('draft')->comment('Budget status');
$table->foreignId('created_by_user_id')->constrained('users')->cascadeOnDelete()->comment('Created by user');
$table->foreignId('approved_by_user_id')->nullable()->constrained('users')->nullOnDelete()->comment('Approved by user');
$table->timestamp('approved_at')->nullable()->comment('Approval timestamp');
$table->text('notes')->nullable()->comment('Budget notes');
$table->timestamps();
$table->index('fiscal_year');
$table->index('status');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('budgets');
}
};