Repository URL to install this package:
|
Version:
0.2.1 ▾
|
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateExamsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('exams', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->boolean('is_active')->default(true)->index();
if (Module::has('Courses')) {
if (!Schema::hasTable('courses')) {
Artisan::call('module:migrate', ['module' => 'Courses']);
}
$table->integer('course_id')->unsigned()->index()->nullable();
$table->foreign('course_id')->references('id')->on('courses')->onDelete('cascade');
}
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('exams');
}
}