migrations/Version20260405120000.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Drop source-period uniqueness so older firmware counters do not block ingest.
  8.  */
  9. final class Version20260405120000 extends AbstractMigration
  10. {
  11.     public function getDescription() : string
  12.     {
  13.         return 'Drop source period/item unique indexes while keeping replay metadata columns.';
  14.     }
  15.     public function up(Schema $schema) : void
  16.     {
  17.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql''Migration can only be executed safely on \'postgresql\'.');
  18.         $this->addSql('DROP INDEX IF EXISTS UNIQ_M_DEV_PERIOD');
  19.         $this->addSql('DROP INDEX IF EXISTS UNIQ_DS_DEV_PERIOD_ITEM');
  20.     }
  21.     public function down(Schema $schema) : void
  22.     {
  23.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql''Migration can only be executed safely on \'postgresql\'.');
  24.         $this->addSql('CREATE UNIQUE INDEX UNIQ_DS_DEV_PERIOD_ITEM ON data_samples (device_id, source_period, source_item) WHERE source_period IS NOT NULL AND source_item IS NOT NULL');
  25.         $this->addSql('CREATE UNIQUE INDEX UNIQ_M_DEV_PERIOD ON measurements (device_id, source_period) WHERE source_period IS NOT NULL');
  26.     }
  27. }