From 4e85799403bd21c5c5500241385cf8fef6862be5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Kv=C3=A1=C4=8Dek?= Date: Thu, 18 Feb 2016 11:35:09 +0100 Subject: [PATCH] FEATURE #1452: add table for template paths. We will not store template directories along with the templates. Templates are now binded to their paths using ID of row in database --- ..._100743_CreateTemplateDirectoriesTable.php | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 database/migrations/2016_02_18_100743_CreateTemplateDirectoriesTable.php diff --git a/database/migrations/2016_02_18_100743_CreateTemplateDirectoriesTable.php b/database/migrations/2016_02_18_100743_CreateTemplateDirectoriesTable.php new file mode 100644 index 00000000..a723fc9e --- /dev/null +++ b/database/migrations/2016_02_18_100743_CreateTemplateDirectoriesTable.php @@ -0,0 +1,63 @@ +integer('id', true); + $table->timestamps(); + $table->string('path') + ->comment('Path on filesystem'); + }); + + Schema::table('templates', function (Blueprint $table) { + $table->integer('path') + ->comment('ID of template directory') + ->change(); + + $table->index('path'); + + $table->foreign('path') + ->references('id') + ->on('template_paths') + ->onDelete('cascade') + ->onUpdate('cascade'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + + // drop FK from templates dir + Schema::table('templates', function (Blueprint $table) { + $table->dropForeign('templates_path_foreign'); + }); + + // drop template_paths + Schema::drop('template_paths'); + + // change path column to its original state + Schema::table('templates', function (Blueprint $table) { + $table->string('path') + ->comment('Path to this template. Given as relative path for theme directory.') + ->change(); + + $table->dropIndex('templates_path_index'); + }); + } +}