Files
pictureFrame-webApp/migrations/Version20260507230001.php
football2801 d11ddff912
CI / test (push) Has been cancelled
feat(device): replace daily wakeHour with multi-time wakeTimes (minutes)
Frame settings now offer two update-frequency modes: "at specific times" or
"every X minutes". Times are stored as an int[] of minutes-since-midnight,
allowing multiple slots per day at minute granularity. Backend computes the
earliest upcoming slot for X-Interval-Ms and uses the most-recent-past slot
as the rotation-due boundary. PWA settings sheet has hour/minute/AM-PM
dropdowns with + Add / trash, a live "next update" preview, and a note
that changes only take effect at the device's next sync.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 14:32:58 -04:00

31 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20260507230001 extends AbstractMigration
{
public function getDescription(): string
{
return 'Replace device.wake_hour (single int hour) with device.wake_times (JSON array of minutes-since-midnight, 0-1439)';
}
public function up(Schema $schema): void
{
$this->addSql("ALTER TABLE device ADD wake_times JSON NOT NULL DEFAULT '[]'");
$this->addSql("UPDATE device SET wake_times = json_build_array(wake_hour * 60) WHERE wake_hour IS NOT NULL");
$this->addSql('ALTER TABLE device DROP COLUMN wake_hour');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE device ADD wake_hour INT DEFAULT NULL');
$this->addSql("UPDATE device SET wake_hour = ((wake_times->>0)::int / 60) WHERE jsonb_array_length(wake_times::jsonb) > 0");
$this->addSql('ALTER TABLE device DROP COLUMN wake_times');
}
}