%PDF- %PDF-
Direktori : /var/www/html/shaban/duassis/api/database/migrations/ |
Current File : //var/www/html/shaban/duassis/api/database/migrations/2020_06_08_160207_create_posts_table.php |
<?php use App\Models\Post; 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->string('title'); $table->string('type') ->default(Post::GAME_TYPE); $table->dateTime('expires_at') ->nullable(); $table->unsignedBigInteger('category_id') ->index(); $table->foreign('category_id') ->references('id') ->on('categories') ->onDelete('cascade'); $table->unsignedBigInteger('field_id') ->nullable() ->index(); $table->foreign('field_id') ->references('id') ->on('fields') ->onDelete('cascade'); $table->unsignedBigInteger('author_id') ->index(); $table->foreign('author_id') ->references('id') ->on('users') ->onDelete('cascade'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('posts'); } }