FEATURE #1419: add admin for creating new widget area

This commit is contained in:
Michal Kváček
2016-02-15 10:26:39 +01:00
parent d7dbdf7fc5
commit 012b8b7588
7 changed files with 214 additions and 1 deletions
@@ -0,0 +1,67 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class FixAutoIncrementForWidgetAreas extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
try {
Schema::table('widget_in_widget_area', function (Blueprint $table) {
$table->dropForeign('fk_widget_has_widget_area_widget_area1');
});
} catch (\Illuminate\Database\QueryException $e) {
// probably foreign does not exist, try to remove one from migration
try {
Schema::table('widget_in_widget_area', function (Blueprint $table) {
$table->dropForeign('widget_in_widget_area_widget_area_id_foreign');
});
} catch (\Illuminate\Database\QueryException $ex) {
// ignore this error
}
}
Schema::table('widget_areas', function (Blueprint $table) {
$table->integer('id', true)->change();
});
Schema::table('widget_in_widget_area', function(Blueprint $table) {
$table->foreign('widget_area_id')
->references('id')
->on('widget_areas')
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('widget_in_widget_area', function (Blueprint $table) {
$table->dropForeign('widget_in_widget_area_widget_area_id_foreign');
});
Schema::table('widget_areas', function (Blueprint $table) {
$table->integer('id', false)->change();
});
Schema::table('widget_in_widget_area', function(Blueprint $table) {
$table->foreign('widget_area_id')
->references('id')
->on('widget_areas')
->onDelete('cascade');
});
}
}