mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
adapt migrations files to flex
This commit is contained in:
parent
f760943baa
commit
f707a649d1
@ -2,7 +2,7 @@
|
||||
|
||||
namespace Application\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Migrations\AbstractMigration;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
@ -10,7 +10,7 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
*/
|
||||
class Version20141129012050 extends AbstractMigration
|
||||
{
|
||||
public function up(Schema $schema)
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql("CREATE SEQUENCE Report_id_seq INCREMENT BY 1 MINVALUE 1 START 1;");
|
||||
$this->addSql("CREATE TABLE Report (id INT NOT NULL, user_id INT DEFAULT NULL, person_id INT DEFAULT NULL, date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, scope VARCHAR(255) DEFAULT NULL, cFData JSON NOT NULL, cFGroup_id INT DEFAULT NULL, PRIMARY KEY(id));");
|
||||
@ -22,7 +22,7 @@ class Version20141129012050 extends AbstractMigration
|
||||
$this->addSql("ALTER TABLE Report ADD CONSTRAINT FK_C38372B216D2C9F0 FOREIGN KEY (cFGroup_id) REFERENCES CustomFieldsGroup (id) NOT DEFERRABLE INITIALLY IMMEDIATE;");
|
||||
}
|
||||
|
||||
public function down(Schema $schema)
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace Application\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Migrations\AbstractMigration;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
@ -15,6 +15,7 @@ use Chill\MainBundle\Entity\Scope;
|
||||
class Version20150622233319 extends AbstractMigration
|
||||
implements ContainerAwareInterface
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var ContainerInterface
|
||||
@ -34,13 +35,23 @@ class Version20150622233319 extends AbstractMigration
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema)
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql',
|
||||
'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE report ADD scope_id INT DEFAULT NULL');
|
||||
|
||||
/*
|
||||
* Before the upgrade to symfony version 4, this code worked.
|
||||
*
|
||||
* But it doesn't work any more after the migration and currently this
|
||||
* code should note be necessary.
|
||||
*
|
||||
* This code is kept for reference, and may be re-activated if needed, but
|
||||
* the probability that this will happens is near 0
|
||||
*
|
||||
|
||||
//add a default scope
|
||||
$scopes = $this->container->get('doctrine.orm.default_entity_manager')
|
||||
->getRepository('ChillMainBundle:Scope')
|
||||
@ -73,7 +84,7 @@ class Version20150622233319 extends AbstractMigration
|
||||
//default scope is the newly-created one
|
||||
$defaultScopeId = $scope->getId();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
$this->addSql('ALTER TABLE report DROP scope'); //before this migration, scope was never used
|
||||
$this->addSql('ALTER TABLE report ADD CONSTRAINT FK_report_scope '
|
||||
@ -92,7 +103,7 @@ class Version20150622233319 extends AbstractMigration
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema)
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql',
|
||||
'Migration can only be executed safely on \'postgresql\'.');
|
Loading…
x
Reference in New Issue
Block a user