2021_06_07_08638_create_keywords_table.php 1.85 KB
<?php

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

class CreateKeywordsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('keywords', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('external_id')->nullable();
            $table->bigInteger('ad_group_external_id')->nullable();
            $table->bigInteger('ad_group_id')->unsigned();
            $table->text('keyword')->nullable();
            $table->string('user_param_1', 255)->nullable();
            $table->string('user_param_2', 255)->nullable();
            $table->bigInteger('bid')->nullable();
            $table->bigInteger('context_bid')->nullable();
            $table->enum('state', [
                Keyword::STATE_OFF,
                Keyword::STATE_ON,
                Keyword::STATE_SUSPENDED,
            ])->nullable();
            $table->enum('status', [
                Keyword::STATUS_ACCEPTED,
                Keyword::STATUS_DRAFT,
                Keyword::STATUS_REJECTED,
                Keyword::STATUS_UNKNOWN,
            ])->nullable();
            $table->enum('serving_status', [
                Keyword::SERVING_STATUS_ELIGIBLE,
                Keyword::SERVING_STATUS_RARELY_SERVED,
            ])->nullable();
            $table->json('statistics_search')->nullable();
            $table->json('statistics_network')->nullable();
            $table->timestamps();

            $table->foreign('ad_group_id')->references('id')->on('ad_groups')
                ->cascadeOnDelete();
        });
    }

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