mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-04 07:56:12 +00:00
add foreign key from report to scope
This commit is contained in:
parent
1c3c3b14ab
commit
eb066b86aa
@ -24,10 +24,14 @@ use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
|
|||||||
|
|
||||||
namespace Chill\ReportBundle\Entity;
|
namespace Chill\ReportBundle\Entity;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\HasCenterInterface;
|
||||||
|
use Chill\MainBundle\Entity\HasScopeInterface;
|
||||||
|
use Chill\MainBundle\Entity\Scope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report
|
* Report
|
||||||
*/
|
*/
|
||||||
class Report
|
class Report implements HasCenterInterface, HasScopeInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var integer
|
* @var integer
|
||||||
@ -50,7 +54,7 @@ class Report
|
|||||||
private $date;
|
private $date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var Scope
|
||||||
*/
|
*/
|
||||||
private $scope;
|
private $scope;
|
||||||
|
|
||||||
@ -154,7 +158,7 @@ class Report
|
|||||||
*
|
*
|
||||||
* @return Report
|
* @return Report
|
||||||
*/
|
*/
|
||||||
public function setScope($scope)
|
public function setScope(Scope $scope)
|
||||||
{
|
{
|
||||||
$this->scope = $scope;
|
$this->scope = $scope;
|
||||||
|
|
||||||
@ -164,7 +168,7 @@ class Report
|
|||||||
/**
|
/**
|
||||||
* Get scope
|
* Get scope
|
||||||
*
|
*
|
||||||
* @return string
|
* @return Scope
|
||||||
*/
|
*/
|
||||||
public function getScope()
|
public function getScope()
|
||||||
{
|
{
|
||||||
@ -218,4 +222,10 @@ class Report
|
|||||||
{
|
{
|
||||||
return $this->cFGroup;
|
return $this->cFGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getCenter()
|
||||||
|
{
|
||||||
|
return $this->person->getCenter();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -10,10 +10,6 @@ Chill\ReportBundle\Entity\Report:
|
|||||||
fields:
|
fields:
|
||||||
date:
|
date:
|
||||||
type: datetime
|
type: datetime
|
||||||
scope:
|
|
||||||
type: string
|
|
||||||
length: 255
|
|
||||||
nullable: true # TO REMOVE IF SCOPE IS USED
|
|
||||||
cFData:
|
cFData:
|
||||||
type: json_array
|
type: json_array
|
||||||
manyToOne:
|
manyToOne:
|
||||||
@ -21,6 +17,8 @@ Chill\ReportBundle\Entity\Report:
|
|||||||
targetEntity: Chill\MainBundle\Entity\User
|
targetEntity: Chill\MainBundle\Entity\User
|
||||||
person:
|
person:
|
||||||
targetEntity: Chill\PersonBundle\Entity\Person
|
targetEntity: Chill\PersonBundle\Entity\Person
|
||||||
|
scope:
|
||||||
|
targetEntity: Chill\MainBundle\Entity\Scope
|
||||||
cFGroup:
|
cFGroup:
|
||||||
targetEntity: Chill\CustomFieldsBundle\Entity\CustomFieldsGroup
|
targetEntity: Chill\CustomFieldsBundle\Entity\CustomFieldsGroup
|
||||||
lifecycleCallbacks: { }
|
lifecycleCallbacks: { }
|
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');
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user