2021_06_15_104738_create_advertisements_table.php 4.81 KB
<?php

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

class CreateAdvertisementsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('advertisements', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('external_id')->nullable();
            $table->bigInteger('campaign_external_id')->nullable();
            $table->bigInteger('ad_group_external_id')->nullable();
            $table->bigInteger('campaign_id')->unsigned();
            $table->bigInteger('ad_group_id')->unsigned();

            $table->enum('status', [
                Advertisement::STATUS_ACCEPTED,
                Advertisement::STATUS_DRAFT,
                Advertisement::STATUS_MODERATION,
                Advertisement::STATUS_PREACCEPTED,
                Advertisement::STATUS_REJECTED,
                Advertisement::STATUS_UNKNOWN,
            ])->nullable();
            $table->enum('state', [
                Advertisement::STATE_OFF,
                Advertisement::STATE_ON,
                Advertisement::STATE_SUSPENDED,
                Advertisement::STATE_OFF_BY_MONITORING,
                Advertisement::STATE_ARCHIVED,
                Advertisement::STATE_UNKNOWN,
            ])->nullable();
            $table->string('status_clarification')->nullable();
            $table->json('ad_categories')->nullable();
            $table->enum('age_label', [
                Advertisement::AGE_LABEL_0,
                Advertisement::AGE_LABEL_6,
                Advertisement::AGE_LABEL_12,
                Advertisement::AGE_LABEL_16,
                Advertisement::AGE_LABEL_18,
                Advertisement::AGE_LABEL_MONTHS_0,
                Advertisement::AGE_LABEL_MONTHS_1,
                Advertisement::AGE_LABEL_MONTHS_2,
                Advertisement::AGE_LABEL_MONTHS_3,
                Advertisement::AGE_LABEL_MONTHS_4,
                Advertisement::AGE_LABEL_MONTHS_5,
                Advertisement::AGE_LABEL_MONTHS_6,
                Advertisement::AGE_LABEL_MONTHS_7,
                Advertisement::AGE_LABEL_MONTHS_8,
                Advertisement::AGE_LABEL_MONTHS_9,
                Advertisement::AGE_LABEL_MONTHS_10,
                Advertisement::AGE_LABEL_MONTHS_11,
                Advertisement::AGE_LABEL_MONTHS_12,
            ])->nullable();
            $table->enum('type', [
                Advertisement::TYPE_TEXT_AD,
                Advertisement::TYPE_MOBILE_APP_AD,
                Advertisement::TYPE_DYNAMIC_TEXT_AD,
                Advertisement::TYPE_IMAGE_AD,
                Advertisement::TYPE_CPC_VIDEO_AD,
                Advertisement::TYPE_CPM_BANNER_AD,
                Advertisement::TYPE_CPM_VIDEO_AD,
                Advertisement::TYPE_SMART_AD,
            ])->nullable();
            $table->enum('sub_type', [
                Advertisement::SUB_TYPE_NONE,
                Advertisement::SUB_TYPE_TEXT_IMAGE_AD,
                Advertisement::SUB_TYPE_MOBILE_APP_IMAGE_AD,
                Advertisement::SUB_TYPE_MOBILE_APP_CPC_VIDEO_AD_BUILDER_AD,
                Advertisement::SUB_TYPE_TEXT_AD_BUILDER_AD,
                Advertisement::SUB_TYPE_MOBILE_APP_AD_BUILDER_AD,
            ])->nullable();

            $table->string('title')->nullable();
            $table->string('title2')->nullable();
            $table->string('text')->nullable();
            $table->string('href')->nullable();
            $table->boolean('mobile')->nullable();
            $table->string('display_domain')->nullable();
            $table->string('display_url_path')->nullable();
            $table->bigInteger('v_card_id')->nullable();
            $table->string('ad_image_hash')->nullable();
            $table->string('site_link_set_id')->nullable();
            $table->json('display_url_path_moderation')->nullable();
            $table->json('v_card_moderation')->nullable();
            $table->json('site_links_moderation')->nullable();
            $table->json('ad_image_moderation')->nullable();
            $table->json('ad_extensions')->nullable();
            $table->json('video_extension')->nullable();
            $table->json('price_extension')->nullable();
            $table->bigInteger('turbo_page_id')->nullable();
            $table->bigInteger('turbo_page_moderation')->nullable();
            $table->bigInteger('business_id')->nullable();
            $table->boolean('prefer_v_card_over_business')->nullable();

            $table->timestamp('updated_self')->nullable();

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

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