You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2023_05_11_044321_create_accounts_table.php 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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('accounts', function (Blueprint $table) {
  13. $table->id();
  14. $table->foreignId('company_id')->constrained()->cascadeOnDelete();
  15. $table->string('type')->default('checking');
  16. $table->string('name', 100)->index();
  17. $table->string('number', 20);
  18. $table->string('currency_code')->default('USD');
  19. $table->double('opening_balance', 15, 4)->default(0.0000);
  20. $table->string('description')->nullable();
  21. $table->text('notes')->nullable();
  22. $table->string('status')->default('open');
  23. $table->string('bank_name', 100)->nullable();
  24. $table->string('bank_phone', 20)->nullable();
  25. $table->text('bank_address')->nullable();
  26. $table->string('bank_website', 255)->nullable();
  27. $table->string('bic_swift_code', 11)->nullable();
  28. $table->string('iban', 34)->nullable();
  29. $table->string('aba_routing_number', 9)->nullable();
  30. $table->string('ach_routing_number', 9)->nullable();
  31. $table->boolean('enabled')->default(true);
  32. $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
  33. $table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
  34. $table->timestamps();
  35. $table->unique(['company_id', 'number']);
  36. $table->foreign('currency_code')->references('code')->on('currencies')->restrictOnDelete();
  37. });
  38. }
  39. /**
  40. * Reverse the migrations.
  41. */
  42. public function down(): void
  43. {
  44. Schema::dropIfExists('accounts');
  45. }
  46. };