diff --git a/database/migrations/2016_02_18_122645_RemoveModuleIdFromTemplates.php b/database/migrations/2016_02_18_122645_RemoveModuleIdFromTemplates.php new file mode 100644 index 00000000..0b5d1457 --- /dev/null +++ b/database/migrations/2016_02_18_122645_RemoveModuleIdFromTemplates.php @@ -0,0 +1,45 @@ +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'); + }); + } +} diff --git a/database/migrations/2016_02_18_132248_AddNameAndParentIdToTemplatePaths.php b/database/migrations/2016_02_18_132248_AddNameAndParentIdToTemplatePaths.php new file mode 100644 index 00000000..5f409f67 --- /dev/null +++ b/database/migrations/2016_02_18_132248_AddNameAndParentIdToTemplatePaths.php @@ -0,0 +1,50 @@ +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'); + }); + } +}