fix migrations

This commit is contained in:
ShuriZma 2023-10-09 23:19:06 +02:00
parent 6a3b0ba590
commit fa32498fda
Signed by: ShuriZma
GPG Key ID: 8D289758EE9B8074
2 changed files with 34 additions and 4 deletions

View File

@ -21,10 +21,6 @@ return new class extends Migration
$table->integer('seats');
$table->double('price');
$table->double('top_speed');
$table->foreignId('vehicle_class_id')->references('id')->on('vehicle_classes');
$table->foreignId('fuel_type_id')->references('id')->on('fuel_types');
$table->foreignId('brand_id')->references('id')->on('brands');
$table->foreignId('vendor_id')->references('id')->on('vendors');
});
}

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('vehicles', function (Blueprint $table) {
$table->foreignId('vehicle_class_id')->references('id')->on('vehicle_classes');
$table->foreignId('fuel_type_id')->references('id')->on('fuel_types');
$table->foreignId('brand_id')->references('id')->on('brands');
$table->foreignId('vendor_id')->references('id')->on('vendors');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('vehicles', function (Blueprint $table) {
$table->dropConstrainedForeignId('vehicle_class_id');
$table->dropConstrainedForeignId('fuel_type_id');
$table->dropConstrainedForeignId('brand_id');
$table->dropConstrainedForeignId('vendor_id');
});
}
};