WIP: weather integration
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260811120000 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add task scheduling and recurrence fields.';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE task ADD scheduled_for DATE DEFAULT NULL, ADD recurrence_interval INT DEFAULT NULL, ADD recurrence_unit VARCHAR(10) DEFAULT NULL');
|
||||
$this->addSql("UPDATE task SET recurrence_interval = 1, recurrence_unit = 'day' WHERE is_recurring = 1 AND (recurrence_interval IS NULL OR recurrence_unit IS NULL)");
|
||||
$this->addSql('UPDATE task SET scheduled_for = DATE(created_at) WHERE scheduled_for IS NULL');
|
||||
$this->addSql('ALTER TABLE task MODIFY scheduled_for DATE NOT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE task DROP scheduled_for, DROP recurrence_interval, DROP recurrence_unit');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260811150000 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add user weather settings, cached daily forecasts, and task weather metadata.';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('CREATE TABLE settings (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, latitude NUMERIC(10, 7) DEFAULT NULL, longitude NUMERIC(10, 7) DEFAULT NULL, location_updated_at DATETIME DEFAULT NULL, UNIQUE INDEX UNIQ_SETTINGS_USER (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4');
|
||||
$this->addSql('CREATE TABLE weather_forecast (id INT AUTO_INCREMENT NOT NULL, settings_id INT NOT NULL, forecast_date DATE NOT NULL, temperature_max DOUBLE PRECISION DEFAULT NULL, temperature_min DOUBLE PRECISION DEFAULT NULL, precipitation_sum DOUBLE PRECISION DEFAULT NULL, precipitation_probability_max INT DEFAULT NULL, rain_sum DOUBLE PRECISION DEFAULT NULL, weather_code INT DEFAULT NULL, fetched_at DATETIME NOT NULL, INDEX IDX_FORECAST_SETTINGS (settings_id), UNIQUE INDEX weather_forecast_settings_day (settings_id, forecast_date), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4');
|
||||
$this->addSql('ALTER TABLE settings ADD CONSTRAINT FK_SETTINGS_USER FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE');
|
||||
$this->addSql('ALTER TABLE weather_forecast ADD CONSTRAINT FK_FORECAST_SETTINGS FOREIGN KEY (settings_id) REFERENCES settings (id) ON DELETE CASCADE');
|
||||
$this->addSql("ALTER TABLE task ADD is_outdoor TINYINT(1) NOT NULL DEFAULT 0, ADD weather_profile VARCHAR(30) NOT NULL DEFAULT 'none'");
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE weather_forecast DROP FOREIGN KEY FK_FORECAST_SETTINGS');
|
||||
$this->addSql('ALTER TABLE settings DROP FOREIGN KEY FK_SETTINGS_USER');
|
||||
$this->addSql('DROP TABLE weather_forecast');
|
||||
$this->addSql('DROP TABLE settings');
|
||||
$this->addSql('ALTER TABLE task DROP is_outdoor, DROP weather_profile');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20260811164537 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20260811191017 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user