chartboard/app/Database/Migrations/2026-03-29-120000_DashboardWidgetsFinerGrid.php
2026-03-30 09:51:33 +05:30

31 lines
844 B
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
/**
* Doubles grid x,y,w,h so layout size stays the same when switching to
* 24 columns and half cellHeight (finer resize steps on the dashboard).
*/
class DashboardWidgetsFinerGrid extends Migration
{
public function up(): 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');
}
public function down(): 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))');
}
}