REFACTORING #1880 @4h30m: another ugly refactoring commit
This commit is contained in:
@@ -26,7 +26,7 @@ class AddUniqueCodeToWidgets extends Migration
|
||||
});
|
||||
|
||||
// migrate data
|
||||
$widgets = \App\Models\Widget::all();
|
||||
$widgets = \App\Models\Widgets\Widget::all();
|
||||
foreach ($widgets as $widget) {
|
||||
$widget->settings = json_decode($widget->settings);
|
||||
if (isset($widget->settings->containerClass)) {
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class RenameColumnInContents extends Migration
|
||||
{
|
||||
protected $columns;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
|
||||
$platform->registerDoctrineTypeMapping('enum', 'string');
|
||||
|
||||
$this->columns = [
|
||||
'user_id',
|
||||
'parent_id',
|
||||
'category_id',
|
||||
'language',
|
||||
'module_handler',
|
||||
'published_from',
|
||||
'published_to',
|
||||
'title_photo',
|
||||
'template',
|
||||
'is_homepage',
|
||||
'title',
|
||||
'url',
|
||||
'meta_keywords',
|
||||
'meta_description',
|
||||
'content',
|
||||
'module_settings',
|
||||
'status'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('contents', function (Blueprint $table) {
|
||||
foreach ($this->columns as $column) {
|
||||
$table->renameColumn($column, camel_case($column));
|
||||
}
|
||||
|
||||
$table->renameColumn('content', 'pageContent');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('contents', function (Blueprint $table) {
|
||||
foreach ($this->columns as $column) {
|
||||
$table->renameColumn(camel_case($column), $column);
|
||||
}
|
||||
|
||||
$table->renameColumn('pageContent', 'content');
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user