mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
add foreign key from report to scope
This commit is contained in:
42
Resources/migrations/Version20150622233319.php
Normal file
42
Resources/migrations/Version20150622233319.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Application\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Add a scope to report
|
||||
*/
|
||||
class Version20150622233319 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema)
|
||||
{
|
||||
$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');
|
||||
$this->addSql('ALTER TABLE report DROP scope'); //before this migration, scope was never used
|
||||
$this->addSql('ALTER TABLE report ADD CONSTRAINT FK_report_scope '
|
||||
. 'FOREIGN KEY (scope_id) '
|
||||
. 'REFERENCES scopes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('CREATE INDEX IDX_report_scope ON report (scope_id)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema)
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql',
|
||||
'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE Report DROP CONSTRAINT FK_C38372B2682B5931');
|
||||
$this->addSql('DROP INDEX IDX_C38372B2682B5931');
|
||||
$this->addSql('ALTER TABLE Report ADD scope VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE Report DROP scope_id');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user