FEATURE #1452: add parent id and name to template_paths table
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class RemoveModuleIdFromTemplates extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('templates', function (Blueprint $table) {
|
||||
$table->dropIndex('templates_module_id_template_name_unique');
|
||||
$table->dropForeign('templates_module_id_foreign');
|
||||
$table->dropColumn('module_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('templates', function (Blueprint $table) {
|
||||
|
||||
$table->integer('module_id')
|
||||
->after('id')
|
||||
->comment('Template belongs to module specified with this ID.');
|
||||
|
||||
$table->index('module_id');
|
||||
$table->unique(['module_id', 'template_name']);
|
||||
|
||||
$table->foreign('module_id')
|
||||
->references('id')
|
||||
->on('modules')
|
||||
->onDelete('cascade')
|
||||
->onUpdate('cascade');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class AddNameAndParentIdToTemplatePaths extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('template_paths', function (Blueprint $table) {
|
||||
$table->string('name')
|
||||
->after('path')
|
||||
->comment('Human readable name');
|
||||
|
||||
$table->integer('parent_id')
|
||||
->after('id')
|
||||
->nullable()
|
||||
->default(null)
|
||||
->comment('ID of parent directory');
|
||||
|
||||
$table->index('parent_id');
|
||||
|
||||
// add FK to self
|
||||
$table->foreign('parent_id')
|
||||
->references('id')
|
||||
->on('template_paths')
|
||||
->onDelete('cascade')
|
||||
->onUpdate('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('template_paths', function (Blueprint $table) {
|
||||
$table->dropForeign('template_paths_parent_id_foreign');
|
||||
$table->dropColumn('parent_id');
|
||||
$table->dropColumn('name');
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user