Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

2025_03_15_191245_create_budgets_table.php 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. return new class extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. */
  10. public function up(): void
  11. {
  12. Schema::create('budgets', function (Blueprint $table) {
  13. $table->id();
  14. $table->foreignId('company_id')->constrained()->cascadeOnDelete();
  15. $table->foreignId('source_budget_id')->nullable()->constrained('budgets')->nullOnDelete();
  16. // Source fiscal year
  17. $table->year('source_fiscal_year')->nullable();
  18. $table->string('source_type')->nullable(); // budget, actuals
  19. $table->string('name');
  20. $table->date('start_date');
  21. $table->date('end_date');
  22. $table->string('status')->default('draft'); // draft, active, closed
  23. $table->string('interval_type')->default('month'); // day, week, month, quarter, year
  24. $table->text('notes')->nullable();
  25. $table->timestamp('approved_at')->nullable();
  26. $table->foreignId('approved_by_id')->nullable()->constrained('users')->nullOnDelete();
  27. $table->timestamp('closed_at')->nullable();
  28. $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
  29. $table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
  30. $table->timestamps();
  31. });
  32. }
  33. /**
  34. * Reverse the migrations.
  35. */
  36. public function down(): void
  37. {
  38. Schema::dropIfExists('budgets');
  39. }
  40. };