2026_04_29_100000_create_contractors_tables.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. public function up(): void
  8. {
  9. Schema::create('contractors', function (Blueprint $table) {
  10. $table->id();
  11. $table->string('name');
  12. $table->string('legal_name');
  13. $table->string('contract_number');
  14. $table->date('contract_date');
  15. $table->string('director_name');
  16. $table->string('organization_form');
  17. $table->string('tax_rate');
  18. $table->text('contract_header');
  19. $table->boolean('hidden')->default(false);
  20. $table->timestamps();
  21. });
  22. Schema::create('contractor_installation_prices', function (Blueprint $table) {
  23. $table->id();
  24. $table->foreignId('contractor_id')
  25. ->constrained('contractors')
  26. ->cascadeOnDelete();
  27. $table->foreignId('product_id')
  28. ->constrained('products')
  29. ->restrictOnDelete();
  30. $table->unsignedInteger('catalog_year');
  31. $table->string('name_in_spec')->nullable();
  32. $table->unsignedBigInteger('price')->default(0);
  33. $table->timestamps();
  34. $table->unique(['contractor_id', 'product_id', 'catalog_year'], 'contractor_price_unique');
  35. });
  36. }
  37. public function down(): void
  38. {
  39. Schema::dropIfExists('contractor_installation_prices');
  40. Schema::dropIfExists('contractors');
  41. }
  42. };