<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateFooterSocialMediaTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('footer_social_media', function (Blueprint $table) {
            $table->unsignedBigInteger('footer_id');
            $table->unsignedBigInteger('social_media_id');
            $table->unsignedInteger('position')->nullable();

            $table->primary(['footer_id', 'social_media_id'], 'footer_social_media_pk');

            $table->foreign('footer_id')->references('id')
                ->on('footer')->onDelete('CASCADE')->onUpdate('CASCADE');

            $table->foreign('social_media_id')->references('id')
                ->on('social_medias')->onDelete('CASCADE')->onUpdate('CASCADE');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('footer_social_media');
    }
}
