adding location to ranges and more control on MyCalendarRanges

This commit is contained in:
2022-06-29 15:28:37 +02:00
parent 809a0a38ab
commit 849e7158e4
13 changed files with 357 additions and 78 deletions

View File

@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Calendar;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20220629095515 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add location on calendar range';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_calendar.calendar_range ADD location_id INT DEFAULT NULL');
$this->addSql('UPDATE chill_calendar.calendar_range SET location_id = n.min FROM (SELECT min(id) FROM public.chill_main_location) AS n');
$this->addSql('ALTER TABLE chill_calendar.calendar_range ALTER COLUMN location_id SET NOT NULL');
$this->addSql('ALTER TABLE chill_calendar.calendar_range ADD CONSTRAINT FK_38D57D0564D218E FOREIGN KEY (location_id) REFERENCES chill_main_location (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_38D57D0564D218E ON chill_calendar.calendar_range (location_id)');
}
public function down(Schema $schema): void
{
$this->addSql('alter table chill_calendar.calendar_range DROP COLUMN location_id');
}
}