Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Chill-project
Chill-Report
Commits
eb066b86
Commit
eb066b86
authored
Jun 22, 2015
by
Julien Fastré
Browse files
add foreign key from report to scope
parent
1c3c3b14
Changes
3
Hide whitespace changes
Inline
Side-by-side
Entity/Report.php
View file @
eb066b86
...
...
@@ -24,10 +24,14 @@ use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
namespace
Chill\ReportBundle\Entity
;
use
Chill\MainBundle\Entity\HasCenterInterface
;
use
Chill\MainBundle\Entity\HasScopeInterface
;
use
Chill\MainBundle\Entity\Scope
;
/**
* Report
*/
class
Report
class
Report
implements
HasCenterInterface
,
HasScopeInterface
{
/**
* @var integer
...
...
@@ -50,7 +54,7 @@ class Report
private
$date
;
/**
* @var
string
* @var
Scope
*/
private
$scope
;
...
...
@@ -154,7 +158,7 @@ class Report
*
* @return Report
*/
public
function
setScope
(
$scope
)
public
function
setScope
(
Scope
$scope
)
{
$this
->
scope
=
$scope
;
...
...
@@ -164,7 +168,7 @@ class Report
/**
* Get scope
*
* @return
string
* @return
Scope
*/
public
function
getScope
()
{
...
...
@@ -218,4 +222,10 @@ class Report
{
return
$this
->
cFGroup
;
}
public
function
getCenter
()
{
return
$this
->
person
->
getCenter
();
}
}
\ No newline at end of file
Resources/config/doctrine/Report.orm.yml
View file @
eb066b86
...
...
@@ -10,10 +10,6 @@ Chill\ReportBundle\Entity\Report:
fields
:
date
:
type
:
datetime
scope
:
type
:
string
length
:
255
nullable
:
true
# TO REMOVE IF SCOPE IS USED
cFData
:
type
:
json_array
manyToOne
:
...
...
@@ -21,6 +17,8 @@ Chill\ReportBundle\Entity\Report:
targetEntity
:
Chill\MainBundle\Entity\User
person
:
targetEntity
:
Chill\PersonBundle\Entity\Person
scope
:
targetEntity
:
Chill\MainBundle\Entity\Scope
cFGroup
:
targetEntity
:
Chill\CustomFieldsBundle\Entity\CustomFieldsGroup
lifecycleCallbacks
:
{
}
\ No newline at end of file
Resources/migrations/Version20150622233319.php
0 → 100644
View file @
eb066b86
<?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'
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment