cattr-app/server-application

View on GitHub
database/migrations/2018_08_22_121825_create_projects_roles_table.php

Summary

Maintainability
A
2 hrs
Test Coverage
<?php

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

class CreateProjectsRolesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('projects_roles', function (Blueprint $table) {
            $table->integer('project_id')->unsigned();
            $table->integer('role_id')->unsigned();
            $table->timestamps();

            $table->foreign('role_id')->references('id')->on('role');
            $table->foreign('project_id')->references('id')->on('projects');

            $table->primary(['project_id', 'role_id'], 'projects_roles_id');
        });
    }

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