%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/diaspora/api/database/migrations/
Upload File :
Create Path :
Current File : /var/www/html/diaspora/api/database/migrations/2019_05_12_123208_create_posts_table.php

<?php

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

class CreatePostsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('posts', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('author_id');
            $table->foreign('author_id')
                  ->references('id')
                  ->on('users');
            $table->string('status')
                  ->default(\App\Models\Post::DRAFT);
            $table->string('video_type')
                  ->nullable();
            $table->string('video_url')
                  ->nullable();
            $table->unsignedBigInteger('category_id');
            $table->unsignedInteger('country_id');
            $table->foreign('category_id')
                  ->references('id')
                  ->on('categories');
            $table->foreign('country_id')
                  ->references('id')
                  ->on('countries');
            $table->timestamps();
        });

        Schema::create('post_translations', function (Blueprint $table) {

            $table->increments('id');
            $table->unsignedBigInteger('post_id');
            $table->string('title');
            $table->longText('content');
            $table->string('locale')
                  ->index();
            $table->unique(['post_id', 'locale']);
            $table->foreign('post_id')
                  ->references('id')
                  ->on('posts')
                  ->onDelete('cascade');
        });

    }

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

Zerion Mini Shell 1.0