move table to schema and remove old migration file

This commit is contained in:
Julien Fastré 2018-06-05 12:06:55 +02:00
parent 3e40bebf45
commit f8b7533e18
3 changed files with 2 additions and 45 deletions

View File

@ -7,6 +7,7 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table("chill_doc.document_category")
* @ORM\Entity(repositoryClass="Chill\DocStoreBundle\EntityRepository\DocumentCategoryRepository")
*/
class DocumentCategory

View File

@ -11,6 +11,7 @@ use Chill\PersonBundle\Entity\Person;
/**
* @ORM\Table("chill_doc.person_document")
* @ORM\Entity()
*/
class PersonDocument extends Document implements HasCenterInterface, HasScopeInterface

View File

@ -1,45 +0,0 @@
<?php
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20180322123800 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
$this->addSql("CREATE SEQUENCE PersonDocument_id_seq INCREMENT BY 1 MINVALUE 1 START 1;");
$this->addSql("CREATE TABLE DocumentCategory (bundle_id VARCHAR(255) NOT NULL, id_inside_bundle INT NOT NULL, name JSON NOT NULL, document_class VARCHAR(255) NOT NULL, PRIMARY KEY(bundle_id, id_inside_bundle));");
$this->addSql("COMMENT ON COLUMN DocumentCategory.name IS '(DC2Type:json_array)';");
$this->addSql("CREATE TABLE PersonDocument (id INT NOT NULL, category_bundle_id VARCHAR(255) DEFAULT NULL, category_id_inside_bundle INT DEFAULT NULL, scope_id INT DEFAULT NULL, user_id INT DEFAULT NULL, person_id INT DEFAULT NULL, title TEXT NOT NULL, description TEXT NOT NULL, content TEXT NOT NULL, date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id));");
$this->addSql("CREATE INDEX IDX_BAADC20C369A0BE36EF62EFC ON PersonDocument (category_bundle_id, category_id_inside_bundle);");
$this->addSql("CREATE INDEX IDX_BAADC20C682B5931 ON PersonDocument (scope_id);");
$this->addSql("CREATE INDEX IDX_BAADC20CA76ED395 ON PersonDocument (user_id);");
$this->addSql("CREATE INDEX IDX_BAADC20C217BBB47 ON PersonDocument (person_id);");
$this->addSql("ALTER TABLE PersonDocument ADD CONSTRAINT FK_BAADC20C369A0BE36EF62EFC FOREIGN KEY (category_bundle_id, category_id_inside_bundle) REFERENCES DocumentCategory (bundle_id, id_inside_bundle) NOT DEFERRABLE INITIALLY IMMEDIATE;");
$this->addSql("ALTER TABLE PersonDocument ADD CONSTRAINT FK_BAADC20C682B5931 FOREIGN KEY (scope_id) REFERENCES scopes (id) NOT DEFERRABLE INITIALLY IMMEDIATE;");
$this->addSql("ALTER TABLE PersonDocument ADD CONSTRAINT FK_BAADC20CA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE;");
$this->addSql("ALTER TABLE PersonDocument ADD CONSTRAINT FK_BAADC20C217BBB47 FOREIGN KEY (person_id) REFERENCES Person (id) NOT DEFERRABLE INITIALLY IMMEDIATE;");
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
$this->addSql("ALTER TABLE PersonDocument DROP CONSTRAINT FK_BAADC20C369A0BE36EF62EFC");
$this->addSql("ALTER TABLE PersonDocument DROP CONSTRAINT FK_BAADC20C682B5931");
$this->addSql("ALTER TABLE PersonDocument DROP CONSTRAINT FK_BAADC20CA76ED395");
$this->addSql("ALTER TABLE PersonDocument DROP CONSTRAINT FK_BAADC20C217BBB47");
$this->addSql("DROP TABLE DocumentCategory;");
$this->addSql("DROP TABLE PersonDocument;");
$this->addSql("DROP SEQUENCE PersonDocument_id_seq;");
}
}