Add Pivot table for the relationship between Cities and Companies.

This commit is contained in:
2023-06-19 21:47:23 +03:00
parent 962b423d0d
commit f7214205d8
3 changed files with 47 additions and 0 deletions
@@ -0,0 +1,35 @@
<?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::create('cities_companies', function (Blueprint $table) {
$table->id();
$table->unsignedBiginteger('city_id')->unsigned();
$table->unsignedBiginteger('company_id')->unsigned();
$table->foreign('city_id')->references('id')
->on('cities')->onDelete('cascade');
$table->foreign('company_id')->references('id')
->on('companies')->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cities_companies');
}
};