Parcourir la source

feat(tbr): permite user_id nulo em tbr_calculations (geração automática pelo sistema)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ebagabee il y a 4 semaines
Parent
commit
fec73f2ff9

+ 26 - 0
database/migrations/2026_07_01_000005_make_user_id_nullable_on_tbr_calculations.php

@@ -0,0 +1,26 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Permite gerar o TBR automaticamente (schedule mensal) sem um usuário logado.
+     * user_id nulo = gerado pelo sistema.
+     */
+    public function up(): void
+    {
+        Schema::table('tbr_calculations', function (Blueprint $table) {
+            $table->foreignId('user_id')->nullable()->change();
+        });
+    }
+
+    public function down(): void
+    {
+        Schema::table('tbr_calculations', function (Blueprint $table) {
+            $table->foreignId('user_id')->nullable(false)->change();
+        });
+    }
+};