Reputation: 2591
I use Doctrine 2.2.3 and Symfony 2.0.12, I have problem with Doctrine, when I launch doctrine:schema:update it produces the same set of queries again and again, like this:
ALTER TABLE Testimonial CHANGE frontPage frontPage TINYINT(1) NOT NULL;
ALTER TABLE Slider CHANGE active active TINYINT(1) DEFAULT NULL;
ALTER TABLE LPSlider CHANGE active active TINYINT(1) DEFAULT NULL;
ALTER TABLE CustomerDesign CHANGE requestProof requestProof TINYINT(1) DEFAULT NULL, CHANGE isBlank isBlank TINYINT(1) DEFAULT NULL, CHANGE hidden hidden TINYINT(1) DEFAULT NULL;
ALTER TABLE SessionDesign CHANGE requestProof requestProof TINYINT(1) DEFAULT NULL, CHANGE isBlank isBlank TINYINT(1) DEFAULT NULL;
And much more, as you see this is only "TINYINT(1) DEFAULT NULL" changes, if I run command with --force, it's updating schema successfully:
Database schema updated successfully! "30" queries were executed
But if I run again doctrine:schema:update --dump-sql it shows the same queries, I checked database, all this fields already "TINYINT(1) DEFAULT NULL".
I use PHP Entities annotation, example:
/**
* @var boolean $frontPage
*
* @ORM\Column(name="frontPage", type="boolean")
*/
private $frontPage;
I can't update Doctrine to v2.3 or bigger, it doesn't work with my Symfony version, updating Symfony may be real pain as this is really huge project.
UPDATE:
I managed to upgrade application to latest version of Symfony 2.7.5 and Doctrine 2.5.1 and still have the same issue, tried to create new database with doctrine:schema:create, but doctrine:schema:update again shows the same "TINYINT(1) NOT NULL" changes.
Upvotes: 4
Views: 2303
Reputation: 2591
Ok, I finally found the problem, it was in config file where type tinyint was manually mapped to smallint for some reason:
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
mapping_types:
enum: string
tinyint: smallint # this is what caused all the problems with booleand fields
Upvotes: 4
Reputation: 577
I remembre having the same issue in one of my projects.
From the annotations cited in your answer, assume that the most of the columns you have are boolean. MySQL consider boolean type as TINYINT(1), and when doctrine checks the database schema to run the update against, it find TINYINT(1), thus always generating the same set of queries.
Hope this helps if you want to get rid of this issue
credits go to : https://stackoverflow.com/a/4237773/2154099
Upvotes: 1