badgeteam/Hatchery

View on GitHub
database/migrations/2019_09_18_173501_create_warnings_table.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

declare(strict_types=1);

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

class CreateWarningsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create(
            'warnings',
            function (Blueprint $table) {
                $table->bigIncrements('id');
                $table->integer('user_id')->unsigned();
                $table->integer('project_id')->unsigned();
                $table->string('description');
                $table->softDeletes();
                $table->timestamps();
                $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade');
                $table->foreign('project_id')->references('id')->on('projects')->onDelete('cascade')->onUpdate('cascade');
            }
        );
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table(
            'warnings',
            function (Blueprint $table) {
                $table->dropForeign(['user_id']);
                $table->dropForeign(['project_id']);
            }
        );
        Schema::dropIfExists('warnings');
    }
}