2021_06_30_120819_create_ad_extensions_table.php 1.73 KB
<?php

use App\Models\AdExtension;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

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

            $table->bigInteger('token_id')->nullable()->unsigned();
            $table->bigInteger('external_id');
            $table->string('callout_text');
            $table->boolean('associated');
            $table->enum('type', [
                AdExtension::TYPE_CALLOUT,
                AdExtension::TYPE_UNKNOWN,
            ]);
            $table->enum('state', [
                AdExtension::STATE_ON,
                AdExtension::STATE_DELETED,
                AdExtension::STATE_UNKNOWN,
            ]);
            $table->enum('status', [
                AdExtension::STATUS_ACCEPTED,
                AdExtension::STATUS_DRAFT,
                AdExtension::STATUS_MODERATION,
                AdExtension::STATUS_REJECTED,
                AdExtension::STATUS_UNKNOWN,
            ]);
            $table->string('status_clarification');

            $table->foreign('token_id')->references('id')->on('tokens')
                ->cascadeOnDelete();

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

        Schema::table('tokens', function (Blueprint $table) {
            $table->timestamp('check_changes_ad_extension')->nullable();
        });
    }

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