Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

2024_01_01_234943_create_transactions_table.php 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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('transactions', function (Blueprint $table) {
  13. $table->id();
  14. $table->foreignId('company_id')->constrained()->cascadeOnDelete();
  15. $table->foreignId('account_id')->nullable()->constrained()->nullOnDelete();
  16. $table->foreignId('bank_account_id')->nullable()->constrained()->nullOnDelete();
  17. $table->string('plaid_transaction_id')->nullable();
  18. $table->foreignId('contact_id')->nullable()->constrained()->nullOnDelete();
  19. $table->string('type'); // deposit, withdrawal, journal
  20. $table->string('payment_channel')->nullable(); // online, in store, other
  21. $table->string('description')->nullable();
  22. $table->text('notes')->nullable();
  23. $table->string('reference')->nullable();
  24. $table->bigInteger('amount')->default(0);
  25. $table->boolean('pending')->default(false);
  26. $table->boolean('reviewed')->default(false);
  27. $table->dateTime('posted_at');
  28. $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
  29. $table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
  30. $table->timestamps();
  31. $table->index(['account_id', 'posted_at']);
  32. $table->index(['bank_account_id', 'posted_at']);
  33. });
  34. }
  35. /**
  36. * Reverse the migrations.
  37. */
  38. public function down(): void
  39. {
  40. Schema::dropIfExists('transactions');
  41. }
  42. };