30 lines
816 B
PHP
30 lines
816 B
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
/**
|
|
* Undoes DashboardWidgetsFinerGrid: restore 12-column coordinates in DB after reverting GridStack to 12 cols.
|
|
*/
|
|
class RevertDashboardWidgetsFinerGrid extends Migration
|
|
{
|
|
public function up(): void
|
|
{
|
|
$this->db->query('UPDATE `dashboard_widgets` SET
|
|
`grid_x` = FLOOR(`grid_x` / 2),
|
|
`grid_y` = FLOOR(`grid_y` / 2),
|
|
`grid_w` = GREATEST(1, FLOOR(`grid_w` / 2)),
|
|
`grid_h` = GREATEST(1, FLOOR(`grid_h` / 2))');
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
$this->db->query('UPDATE `dashboard_widgets` SET
|
|
`grid_x` = `grid_x` * 2,
|
|
`grid_y` = `grid_y` * 2,
|
|
`grid_w` = `grid_w` * 2,
|
|
`grid_h` = `grid_h` * 2');
|
|
}
|
|
}
|