| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- use Illuminate\Database\Migrations\Migration;
- use Illuminate\Database\Schema\Blueprint;
- use Illuminate\Support\Facades\Schema;
- return new class extends Migration
- {
- public function up(): void
- {
- Schema::create('contractors', function (Blueprint $table) {
- $table->id();
- $table->string('name');
- $table->string('legal_name');
- $table->string('contract_number');
- $table->date('contract_date');
- $table->string('director_name');
- $table->string('organization_form');
- $table->string('tax_rate');
- $table->text('contract_header');
- $table->boolean('hidden')->default(false);
- $table->timestamps();
- });
- Schema::create('contractor_installation_prices', function (Blueprint $table) {
- $table->id();
- $table->foreignId('contractor_id')
- ->constrained('contractors')
- ->cascadeOnDelete();
- $table->foreignId('product_id')
- ->constrained('products')
- ->restrictOnDelete();
- $table->unsignedInteger('catalog_year');
- $table->string('name_in_spec')->nullable();
- $table->unsignedBigInteger('price')->default(0);
- $table->timestamps();
- $table->unique(['contractor_id', 'product_id', 'catalog_year'], 'contractor_price_unique');
- });
- }
- public function down(): void
- {
- Schema::dropIfExists('contractor_installation_prices');
- Schema::dropIfExists('contractors');
- }
- };
|