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
This commit is contained in:
Michal Kváček
2016-02-18 11:35:09 +01:00
parent ad457db740
commit 4e85799403
@@ -0,0 +1,63 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTemplateDirectoriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('template_paths', function (Blueprint $table) {
$table->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');
});
}
}