FEATURE: add module id into contents table

This commit is contained in:
Michal Kváček
2016-03-09 21:55:27 +01:00
parent 464eaf8b17
commit bb7106d706
3 changed files with 48 additions and 0 deletions
@@ -0,0 +1,46 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddModuleIdToTemplatesAgain extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('templates', function (Blueprint $table) {
$table->integer('module_id')
->after('id')
->nullable()
->default(null)
->comment('Template belongs to module specified with this ID.');
$table->index('module_id');
$table->foreign('module_id')
->references('id')
->on('modules')
->onDelete('cascade')
->onUpdate('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('templates', function (Blueprint $table) {
$table->dropForeign('templates_module_id_foreign');
$table->dropColumn('module_id');
});
}
}