<?php

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

class CreateFooterLogoLinksTables extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('footer_content_social_links', function (Blueprint $table) {
            $table->unsignedInteger('footer_content_id');
            $table->unsignedInteger('social_link_id');
            $table->unsignedInteger('position');
            $table->primary(['footer_content_id', 'social_link_id'], 'PK_Footer_social_links1');

            $table->foreign('footer_content_id')
                ->references('id')->on('footer_contents')
                ->onDelete('CASCADE')->onUpdate('CASCADE');
            $table->foreign('social_link_id')
                ->references('id')->on('logo_links')
                ->onDelete('CASCADE')->onUpdate('CASCADE');

        });

        Schema::create('footer_content_partner_logos', function (Blueprint $table) {
            $table->unsignedInteger('footer_content_id');
            $table->unsignedInteger('partner_logo_id');
            $table->unsignedInteger('position');
            $table->primary(['footer_content_id', 'partner_logo_id'], 'PK_Footer_parter_logos');

            $table->foreign('footer_content_id')
                ->references('id')->on('footer_contents')
                ->onDelete('CASCADE')->onUpdate('CASCADE');
            $table->foreign('partner_logo_id')
                ->references('id')->on('logo_links')
                ->onDelete('CASCADE')->onUpdate('CASCADE');

        });
    }

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