Add unique constraint for analytics.
This commit is contained in:
parent
c8bb6df218
commit
073c669666
|
@ -10,6 +10,8 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
/**
|
||||
* @ORM\Table(name="analytics", indexes={
|
||||
* @ORM\Index(name="search_idx", columns={"type", "moment"})
|
||||
* }, uniqueConstraints={
|
||||
* @ORM\UniqueConstraint(name="stats_unique_idx", columns={"station_id", "type", "moment"})
|
||||
* })
|
||||
* @ORM\Entity
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity\Migration;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20201109203951 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add unique constraint for analytics.';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE UNIQUE INDEX stats_unique_idx ON analytics (station_id, type, moment)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('DROP INDEX stats_unique_idx ON analytics');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue