Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

2023_09_08_024259_create_discounts_table.php 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. use App\Enums\DiscountComputation;
  3. use App\Enums\DiscountType;
  4. use Illuminate\Database\Migrations\Migration;
  5. use Illuminate\Database\Schema\Blueprint;
  6. use Illuminate\Support\Facades\Schema;
  7. return new class extends Migration
  8. {
  9. /**
  10. * Run the migrations.
  11. */
  12. public function up(): void
  13. {
  14. Schema::create('discounts', function (Blueprint $table) {
  15. $table->id();
  16. $table->foreignId('company_id')->constrained()->cascadeOnDelete();
  17. $table->string('name')->index();
  18. $table->string('description')->nullable();
  19. $table->integer('rate')->default(0);
  20. $table->string('computation')->default(DiscountComputation::DEFAULT);
  21. $table->string('type')->default(DiscountType::DEFAULT);
  22. $table->string('scope')->nullable();
  23. $table->dateTime('start_date')->nullable();
  24. $table->dateTime('end_date')->nullable();
  25. $table->boolean('enabled')->default(true);
  26. $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
  27. $table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
  28. $table->timestamps();
  29. $table->unique(['company_id', 'name', 'type']);
  30. });
  31. }
  32. /**
  33. * Reverse the migrations.
  34. */
  35. public function down(): void
  36. {
  37. Schema::dropIfExists('discounts');
  38. }
  39. };