2025_12_19_093353_create_financial_movements_table.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. use App\Database\Migrations\TenantMigration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. return new class extends TenantMigration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create('financial_movements', function (Blueprint $table) {
  15. $table->id();
  16. $table->dateTime('date');
  17. $table->foreignId('origin_id')->constrained('banks')->cascadeOnUpdate();
  18. $table->foreignId('destination_id')->constrained('banks')->cascadeOnUpdate();
  19. $table->decimal('amount', 12, 2);
  20. $table->foreignId('causal_id')->constrained('causals')->cascadeOnUpdate();
  21. $table->text('notes')->nullable();
  22. $table->boolean('deleted')->default(false);
  23. $table->timestamps();
  24. $table->index(['date', 'origin_id', 'destination_id']);
  25. });
  26. }
  27. /**
  28. * Reverse the migrations.
  29. *
  30. * @return void
  31. */
  32. public function down()
  33. {
  34. Schema::dropIfExists('financial_movements');
  35. }
  36. };