mirror of
https://github.com/ceratic/MediaCollectorLibary.git
synced 2026-05-13 23:56:46 +02:00
...
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use App\Database\Database;
|
||||
|
||||
class CreateActorMediaPivotTables extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$capsule = Database::getCapsule();
|
||||
|
||||
// Pivot table for actors and movies
|
||||
$capsule->schema()->create('actor_movie', function ($table) {
|
||||
$table->id();
|
||||
$table->foreignId('actor_id')->constrained('actors')->onDelete('cascade');
|
||||
$table->foreignId('movie_id')->constrained('movies')->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['actor_id', 'movie_id']);
|
||||
$table->index(['movie_id', 'actor_id']);
|
||||
});
|
||||
|
||||
// Pivot table for actors and TV shows
|
||||
$capsule->schema()->create('actor_tv_show', function ($table) {
|
||||
$table->id();
|
||||
$table->foreignId('actor_id')->constrained('actors')->onDelete('cascade');
|
||||
$table->foreignId('tv_show_id')->constrained('tv_shows')->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['actor_id', 'tv_show_id']);
|
||||
$table->index(['tv_show_id', 'actor_id']);
|
||||
});
|
||||
|
||||
// Pivot table for actors and TV episodes
|
||||
$capsule->schema()->create('actor_tv_episode', function ($table) {
|
||||
$table->id();
|
||||
$table->foreignId('actor_id')->constrained('actors')->onDelete('cascade');
|
||||
$table->foreignId('tv_episode_id')->constrained('tv_episodes')->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['actor_id', 'tv_episode_id']);
|
||||
$table->index(['tv_episode_id', 'actor_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$capsule = Database::getCapsule();
|
||||
|
||||
$capsule->schema()->dropIfExists('actor_tv_episode');
|
||||
$capsule->schema()->dropIfExists('actor_adult_video');
|
||||
$capsule->schema()->dropIfExists('actor_tv_show');
|
||||
$capsule->schema()->dropIfExists('actor_movie');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user