FEATURE #1419: add admin for creating new widget area
This commit is contained in:
@@ -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');
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user