Comment DB unique constraint (post_id, number). New migration.
This commit is contained in:
parent
a12bf9d9a2
commit
b0a6fbfb7f
28
app/DoctrineMigrations/Version20190227233244.php
Normal file
28
app/DoctrineMigrations/Version20190227233244.php
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Application\Migrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20190227233244 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function up(Schema $schema) : void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||||
|
|
||||||
|
$this->addSql('CREATE UNIQUE INDEX unique_post_id_comment_number ON posts.comments (post_id, number)');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema) : void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||||
|
|
||||||
|
$this->addSql('DROP INDEX posts.unique_post_id_comment_number');
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,8 @@ use Skobkin\Bundle\PointToolsBundle\Entity\User;
|
||||||
/**
|
/**
|
||||||
* @ORM\Table(name="comments", schema="posts", indexes={
|
* @ORM\Table(name="comments", schema="posts", indexes={
|
||||||
* @ORM\Index(name="idx_comment_created_at", columns={"created_at"})
|
* @ORM\Index(name="idx_comment_created_at", columns={"created_at"})
|
||||||
|
* }, uniqueConstraints={
|
||||||
|
* @ORM\UniqueConstraint(name="unique_post_id_comment_number", columns={"post_id", "number"})
|
||||||
* })
|
* })
|
||||||
* @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Repository\Blogs\CommentRepository")
|
* @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Repository\Blogs\CommentRepository")
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue