Skip to content

Commit 0f4d98b

Browse files
changed id to uuid (#24)
1 parent e8b6fdd commit 0f4d98b

File tree

6 files changed

+44
-39
lines changed

6 files changed

+44
-39
lines changed

UPGRADE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
UPGRADE
2+
=======
3+
4+
- [0.4.0](#0.4.0)
5+
6+
### 0.4.0
7+
8+
#### Identifier of tasks and executions
9+
10+
The `id` field has been removed in favour of the `uuid`. This field is of
11+
type `guid` and can be used before flush.
12+
13+
To upgrade your table-structure follow following steps:
14+
15+
* Copy the output of `bin/console doctrine:schema:update --dump-sql`.
16+
Its the direct SQL queries to update your schema.
17+
* Connect to mysql (with command shell or your favourite client
18+
* Disable foreign keys checking by running this query:
19+
`set foreign_key_checks=0;`
20+
* Run the queries from `doctrine:schema:update`
21+
* Enable back foreign key checking with : `set foreign_key_checks=1;`

src/Entity/Task.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,11 @@
1919
*/
2020
class Task extends BaseTask
2121
{
22-
/**
23-
* @var int
24-
*/
25-
private $id;
26-
2722
/**
2823
* @var string
2924
*/
3025
private $intervalExpression;
3126

32-
/**
33-
* @return int
34-
*/
35-
public function getId()
36-
{
37-
return $this->id;
38-
}
39-
4027
/**
4128
* @return mixed
4229
*/

src/Entity/TaskExecution.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,4 @@
1818
*/
1919
class TaskExecution extends BaseTaskExecution
2020
{
21-
/**
22-
* @var int
23-
*/
24-
private $id;
25-
26-
/**
27-
* @return int
28-
*/
29-
public function getId()
30-
{
31-
return $this->id;
32-
}
3321
}

src/Handler/TaskHandlerFactory.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,35 @@ class TaskHandlerFactory implements TaskHandlerFactoryInterface
2323
/**
2424
* @var TaskHandlerInterface[]
2525
*/
26-
private $handler = [];
26+
private $handlers = [];
2727

2828
/**
29-
* @param array $handler
29+
* @param TaskHandlerInterface[] $handlers
3030
*/
31-
public function __construct(array $handler)
31+
public function __construct(array $handlers)
3232
{
33-
$this->handler = $handler;
33+
$this->handlers = $handlers;
3434
}
3535

3636
/**
3737
* {@inheritdoc}
3838
*/
3939
public function create($className)
4040
{
41-
if (!array_key_exists($className, $this->handler)) {
41+
if (!array_key_exists($className, $this->handlers)) {
4242
throw new TaskHandlerNotExistsException($className);
4343
}
4444

45-
return $this->handler[$className];
45+
return $this->handlers[$className];
46+
}
47+
48+
/**
49+
* Returns all known handler.
50+
*
51+
* @return TaskHandlerInterface[]
52+
*/
53+
public function getHandlers()
54+
{
55+
return $this->handlers;
4656
}
4757
}

src/Resources/config/doctrine/Task.orm.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99
<index columns="uuid"/>
1010
</indexes>
1111

12-
<id name="id" type="integer">
13-
<generator strategy="AUTO"/>
12+
<id name="uuid" type="guid">
13+
<generator strategy="NONE"/>
1414
</id>
1515

16-
<field name="uuid" type="string" length="100" unique="true"/>
1716
<field name="handlerClass" type="string" length="255"/>
1817
<field name="intervalExpression" type="string" length="255" nullable="true"/>
1918
<field name="firstExecution" type="datetime" nullable="true"/>

src/Resources/config/doctrine/TaskExecution.orm.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
repository-class="Task\TaskBundle\Entity\TaskExecutionRepository">
77

88
<indexes>
9-
<index columns="uuid"/>
109
<index columns="schedule_time"/>
1110
</indexes>
1211

13-
<id name="id" type="integer">
14-
<generator strategy="AUTO"/>
12+
<id name="uuid" type="guid">
13+
<generator strategy="NONE"/>
1514
</id>
1615

17-
<field name="uuid" type="string" length="100" unique="true"/>
1816
<field name="handlerClass" type="string" length="255"/>
1917
<field name="workload" type="object"/>
2018
<field name="duration" type="float" nullable="true"/>
@@ -25,7 +23,9 @@
2523
<field name="result" type="object" nullable="true"/>
2624
<field name="status" type="string" length="20"/>
2725

28-
<many-to-one target-entity="Task\TaskBundle\Entity\Task" field="task"/>
26+
<many-to-one target-entity="Task\TaskBundle\Entity\Task" field="task">
27+
<join-column name="task_id" referenced-column-name="uuid" on-delete="SET NULL"/>
28+
</many-to-one>
2929

3030
</entity>
3131
</doctrine-mapping>

0 commit comments

Comments
 (0)