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_22_073252_create_items_table.php 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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('items', function (Blueprint $table) {
  13. $table->id();
  14. $table->foreignId('company_id')->constrained()->cascadeOnDelete();
  15. $table->string('type'); // product, service
  16. $table->string('name');
  17. $table->string('sku')->unique();
  18. $table->string('description')->nullable();
  19. $table->decimal('sale_price', 15, 4);
  20. $table->decimal('purchase_price', 15, 4);
  21. $table->integer('quantity')->default(1);
  22. $table->foreignId('category_id')->default(1)->constrained()->restrictOnDelete();
  23. $table->foreignId('tax_id')->nullable()->constrained()->nullOnDelete();
  24. $table->foreignId('discount_id')->nullable()->constrained()->nullOnDelete();
  25. $table->boolean('enabled')->default(true);
  26. $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
  27. $table->timestamps();
  28. });
  29. }
  30. /**
  31. * Reverse the migrations.
  32. */
  33. public function down(): void
  34. {
  35. Schema::dropIfExists('items');
  36. }
  37. };