2021_06_21_133314_create_goal_advertisements_table.php 1.6 KB
<?php

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

class CreateGoalAdvertisementsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('goal_advertisements', function (Blueprint $table) {
            $table->id();

            $table->bigInteger('external_id')->nullable();
            $table->bigInteger('dictionary_campaign_external_id')->nullable();
            $table->bigInteger('goal_ad_group_external_id')->nullable();
            $table->bigInteger('dictionary_campaign_id')->unsigned();
            $table->bigInteger('goal_ad_group_id')->unsigned();
            $table->bigInteger('advertisement_id')->unsigned();
            $table->timestamp('external_upload_at')->nullable();
            $table->timestamp('external_updated_at')->nullable();
            $table->timestamp('updated_need')->nullable();

            $table->softDeletes();

            $table->timestamps();


            $table->foreign('dictionary_campaign_id')->references('id')->on('dictionary_campaigns')
                ->cascadeOnDelete();
            $table->foreign('goal_ad_group_id')->references('id')->on('goal_ad_groups')
                ->cascadeOnDelete();
            $table->foreign('advertisement_id')->references('id')->on('advertisements')
                ->cascadeOnDelete();

        });
    }

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