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_23_141215_create_documents_table.php 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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('documents', function (Blueprint $table) {
  13. $table->id();
  14. $table->foreignId('company_id')->constrained()->cascadeOnDelete();
  15. $table->foreignId('document_default_id')->nullable()->constrained()->nullOnDelete();
  16. $table->string('type');
  17. $table->string('document_number');
  18. $table->string('order_number')->nullable();
  19. $table->string('status');
  20. $table->dateTime('document_date');
  21. $table->dateTime('due_date');
  22. $table->dateTime('paid_date')->nullable();
  23. $table->double('amount', 15, 4);
  24. $table->foreignId('tax_id')->nullable()->constrained()->nullOnDelete();
  25. $table->foreignId('discount_id')->nullable()->constrained()->nullOnDelete();
  26. $table->string('reference')->nullable();
  27. $table->string('currency_code')->nullable();
  28. $table->foreignId('category_id')->nullable()->constrained()->nullOnDelete();
  29. $table->foreignId('contact_id')->nullable()->constrained()->nullOnDelete();
  30. $table->text('notes')->nullable();
  31. $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
  32. $table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
  33. $table->timestamps();
  34. $table->foreign('currency_code')->references('code')->on('currencies')->nullOnDelete();
  35. });
  36. }
  37. /**
  38. * Reverse the migrations.
  39. */
  40. public function down(): void
  41. {
  42. Schema::dropIfExists('documents');
  43. }
  44. };