Details
Description
When using the Column annotation on an entity and passing the options parameter to set a default value for a column, the doctrine cli will generate the alter statement every time the schema-tool is run.
This doesn't break the functionality of updating the schema using the cli but when you have multiple entities using default values in this manner it becomes cumbersome to investigate issues during updates that fail and you need to dump the generated sql to examine.
Use case: We have a number of entities that include 'boolean' flags. The data for these entities is inserted into the database through an integration process handled by another application. For all of the flags we want to set a default value of 0 to avoid having to modify the integration scripts when a new flag is added to an entity and the data is not available yet.
Example entity:
/** * @ORM\Entity * @ORM\Table(name="example") */ class Example { /** * @ORM\Id * @ORM\Column(type="integer") */ protected $id; /** @ORM\Column(type="integer", options={"default" = 0}) */ protected $disabled; }
$ php bin/doctrine orm:schema-tool:update --dump-sql ALTER TABLE example CHANGE disabled disabled TINYINT(1) DEFAULT '0' NOT NULL;
This alter statement is generated on every run of the schema-tool even though the schema has already been altered.
Activity
| Field | Original Value | New Value |
|---|---|---|
| Description |
When using the Column annotation on an entity and passing the options parameter to set a default value for a column, the doctrine cli will generate the alter statement every time the schema-tool is run.
This doesn't break the functionality of updating the schema using the cli but when you have multiple entities using default values in this manner it becomes cumbersome to investigate issues during updates that fail and you need to dump the generated sql to examine. Use case: We have a number of entities that include 'boolean' flags. The data for these entities is inserted into the database through an integration process handled by another application. For all of the flags we want to set a default value of 0 to avoid having to modify the integration scripts when a new flag is added to an entity and the data is not available yet. Example entity: /** * @ORM\Entity * @ORM\Table(name="example") */ class Example { /** * @ORM\Id * @ORM\Column(type="integer") */ protected $id; /** @ORM\Column(type="integer", options={"default" = 0}) */ protected $disabled; } $ php bin/doctrine orm:schema-tool:update --dump-sql ALTER TABLE example CHANGE disabled disabled TINYINT(1) DEFAULT '0' NOT NULL; This alter statement is generated on every run of the schema-tool even though the schema has already been altered. |
When using the Column annotation on an entity and passing the options parameter to set a default value for a column, the doctrine cli will generate the alter statement every time the schema-tool is run.
This doesn't break the functionality of updating the schema using the cli but when you have multiple entities using default values in this manner it becomes cumbersome to investigate issues during updates that fail and you need to dump the generated sql to examine. Use case: We have a number of entities that include 'boolean' flags. The data for these entities is inserted into the database through an integration process handled by another application. For all of the flags we want to set a default value of 0 to avoid having to modify the integration scripts when a new flag is added to an entity and the data is not available yet. Example entity: {code} /** * @ORM\Entity * @ORM\Table(name="example") */ class Example { /** * @ORM\Id * @ORM\Column(type="integer") */ protected $id; /** @ORM\Column(type="integer", options={"default" = 0}) */ protected $disabled; } {code} {code} $ php bin/doctrine orm:schema-tool:update --dump-sql ALTER TABLE example CHANGE disabled disabled TINYINT(1) DEFAULT '0' NOT NULL; {code} This alter statement is generated on every run of the schema-tool even though the schema has already been altered. |
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Fix Version/s | 2.3.4 [ 10420 ] | |
| Resolution | Duplicate [ 3 ] |
- Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-2135, expand=changesets[-21:-1].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)
This is fixed for 2.3.4