Bonjour,
Je m'essaie tout juste à Symfony 2 mais je me retrouve déjà devant un souci que je n'arrive pas à résoudre lors de la mise à jour de la base de données...
J'ai créé 2 entities, hospital et department :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208 <?php namespace Gesseh\CoreBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * Gesseh\CoreBundle\Entity\Hospital * * @ORM\Table(name="hospital") * @ORM\Entity(repositoryClass="Gesseh\CoreBundle\Entity\HospitalRepository") */ class Hospital { /** * @var integer $id * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string $name * * @ORM\Column(name="name", type="string", length=255) */ private $name; /** * @var string $address * * @ORM\Column(name="address", type="string", length=255, nullable=true) */ private $address; /** * @var string $web * * @ORM\Column(name="web", type="string", length=255, nullable=true) */ private $web; /** * @var string $phone * * @ORM\Column(name="phone", type="string", length=20, nullable=true) */ private $phone; /** * @var text $description * * @ORM\Column(name="description", type="text", nullable=true) */ private $description; /** * @ORM\OneToMany(targetEntity="Department", mappedBy="hospital", cascade={"remove", "persist"}) */ private $departments; /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set name * * @param string $name */ public function setName($name) { $this->name = $name; } /** * Get name * * @return string */ public function getName() { return $this->name; } /** * Set address * * @param string $address */ public function setAddress($address) { $this->address = $address; } /** * Get address * * @return string */ public function getAddress() { return $this->address; } /** * Set web * * @param string $web */ public function setWeb($web) { $this->web = $web; } /** * Get web * * @return string */ public function getWeb() { return $this->web; } /** * Set phone * * @param string $phone */ public function setPhone($phone) { $this->phone = $phone; } /** * Get phone * * @return string */ public function getPhone() { return $this->phone; } /** * Set description * * @param text $description */ public function setDescription($description) { $this->description = $description; } /** * Get description * * @return text */ public function getDescription() { return $this->description; } public function __construct() { $this->departments = new \Doctrine\Common\Collections\ArrayCollection(); } /** * Add departments * * @param Gesseh\CoreBundle\Entity\Department $departments */ public function addDepartment(\Gesseh\CoreBundle\Entity\Department $departments) { $this->departments[] = $departments; } /** * Set departments * * @param \Doctrine\Common\Collections\Collection $departments */ public function setDepartments(\Doctrine\Common\Collections\Collection $departments) { $this->departments = $departments; } /** * Get departments * * @return Doctrine\Common\Collections\Collection */ public function getDepartments() { return $this->departments; } }Lorsque je crée la base de données tout se passe bien, les tables sont générées correctement, il n'y a pas d'erreur.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141 <?php namespace Gesseh\CoreBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * Gesseh\CoreBundle\Entity\Department * * @ORM\Table(name="department") * @ORM\Entity(repositoryClass="Gesseh\CoreBundle\Entity\DepartmentRepository") */ class Department { /** * @var integer $id * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string $name * * @ORM\Column(name="name", type="string", length=255) */ private $name; /** * @var string $head * * @ORM\Column(name="head", type="string", length=255) */ private $head; /** * @var text $description * * @ORM\Column(name="description", type="text", nullable=true) */ private $description; /** * @ORM\ManyToOne(targetEntity="Hospital", inversedBy="departments", cascade={"remove"}) * @ORM\JoinColumn(name="hospital_id", referencedColumnName="id") */ private $hospital; /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set name * * @param string $name */ public function setName($name) { $this->name = $name; } /** * Get name * * @return string */ public function getName() { return $this->name; } /** * Set head * * @param string $head */ public function setHead($head) { $this->head = $head; } /** * Get head * * @return string */ public function getHead() { return $this->head; } /** * Set description * * @param text $description */ public function setDescription($description) { $this->description = $description; } /** * Get description * * @return text */ public function getDescription() { return $this->description; } /** * Set hospital * * @param Gesseh\CoreBundle\Entity\Hospital $hospital */ public function setHospital(\Gesseh\CoreBundle\Entity\Hospital $hospital) { $this->hospital = $hospital; } /** * Get hospital * * @return Gesseh\CoreBundle\Entity\Hospital */ public function getHospital() { return $this->hospital; } }
Par contre, si j'essaie de mettre à jour le schema, j'ai invariablement ceci :
J'ai d'abord cru à un souci avec mes champs text mais l'erreur est la même quand je les remplace par des string(255), y compris avec une installation neuve de symfony, pour tester.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 $ php app/console doctrine:schema:update --dump-sql -v [Doctrine\DBAL\DBALException] Unknown database type longblob requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it. Exception trace: () at /home/pilou/Public/gesseh/vendor/doctrine-dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php:220 Doctrine\DBAL\Platforms\AbstractPlatform->getDoctrineTypeMapping() at /home/pilou/Public/gesseh/vendor/doctrine-dbal/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php:109 Doctrine\DBAL\Schema\MySqlSchemaManager->_getPortableTableColumnDefinition() at /home/pilou/Public/gesseh/vendor/doctrine-dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php:628 Doctrine\DBAL\Schema\AbstractSchemaManager->_getPortableTableColumnList() at /home/pilou/Public/gesseh/vendor/doctrine-dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php:156 Doctrine\DBAL\Schema\AbstractSchemaManager->listTableColumns() at /home/pilou/Public/gesseh/vendor/doctrine-dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php:226 Doctrine\DBAL\Schema\AbstractSchemaManager->listTableDetails() at /home/pilou/Public/gesseh/vendor/doctrine-dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php:214 Doctrine\DBAL\Schema\AbstractSchemaManager->listTables() at /home/pilou/Public/gesseh/vendor/doctrine-dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php:764 Doctrine\DBAL\Schema\AbstractSchemaManager->createSchema() at /home/pilou/Public/gesseh/vendor/doctrine/lib/Doctrine/ORM/Tools/SchemaTool.php:677 Doctrine\ORM\Tools\SchemaTool->getUpdateSchemaSql() at /home/pilou/Public/gesseh/vendor/doctrine/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php:103 Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand->executeSchemaCommand() at /home/pilou/Public/gesseh/vendor/doctrine/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php:59 Doctrine\ORM\Tools\Console\Command\SchemaTool\AbstractCommand->execute() at /home/pilou/Public/gesseh/vendor/symfony/src/Symfony/Bundle/DoctrineBundle/Command/Proxy/UpdateSchemaDoctrineCommand.php:62 Symfony\Bundle\DoctrineBundle\Command\Proxy\UpdateSchemaDoctrineCommand->execute() at /home/pilou/Public/gesseh/vendor/symfony/src/Symfony/Component/Console/Command/Command.php:224 Symfony\Component\Console\Command\Command->run() at /home/pilou/Public/gesseh/vendor/symfony/src/Symfony/Component/Console/Application.php:194 Symfony\Component\Console\Application->doRun() at /home/pilou/Public/gesseh/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:75 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /home/pilou/Public/gesseh/vendor/symfony/src/Symfony/Component/Console/Application.php:118 Symfony\Component\Console\Application->run() at /home/pilou/Public/gesseh/app/console:22 doctrine:schema:update [--complete] [--dump-sql] [--force] [--em[="..."]]
Comme ce comportement est peu rapporté sur le net, je me dis que j'ai dû simplement oublier une étape mais je ne trouve pas laquelle, même après avoir repris différents tutos sur le net.
Au mieux, j'ai un bug report qui se rapproche (sauf qu'il s'agit là réellement de l'utilisation d'un blob) : http://www.doctrine-project.org/jira/browse/DBAL-197. Par contre, si je lis bien, il faudrait upgrader DBAL à 2.2... mais je doute que Symfony (2.0.10) aprécie beaucoup que je modifie directement ses versions de dépendance dans le fichier deps...
Accessoirement, je tourne avec mysql 5.1.58.
Quelqu'un a une idée ?
Partager