FEATURE: add module id into contents table
This commit is contained in:
@@ -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');
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user