mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Doctrine schema update command shows always few queries to be executed #5748
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jigarpancholi on GitHub (Oct 24, 2017).
Originally assigned to: @jigarpancholi on GitHub.
I am using doctrine with symfony and run
php bin/console doctrine:schema:update --forcecommand. But it executes few queries always as following:ALTER TABLE company CHANGE current_subscription_id current_subscription_id INT DEFAULT NULL, CHANGE city city VARCHAR(255) DEFAULT NULL, CHANGE state state VARCHAR(255) DEFAULT NULL, CHANGE zip zip VARCHAR(255) DEFAULT NULL, CHANGE country country VARCHAR(255) DEFAULT NULL, CHANGE phone phone VARCHAR(255) DEFAULT NULL, CHANGE subscription_start_date subscription_start_date DATE DEFAULT NULL, CHANGE subscription_end_date subscription_end_date DATE DEFAULT NULL;@Ocramius commented on GitHub (Oct 24, 2017):
This needs a test case to validate why this is happening.
@jigarpancholi commented on GitHub (Oct 24, 2017):
@Ocramius do I need to create test case for that?
Because I am using this bundle and this happens only in one project of symfony.
@Ocramius commented on GitHub (Oct 24, 2017):
@jigarpancholi yeah, it needs to be reproduced in isolation. You will need to isolate it via debugging and then either find if the problem is on your side, or whether it is a bug in the ORM.
Start by writing a test in your own application.
@jigarpancholi commented on GitHub (Oct 24, 2017):
@Ocramius this problem occurs only in my local. There is no problem in server. Is there any caching issue in local or anything else?
Or can you please give me an example for test case? So that I can proceed further in debugging.
@Ocramius commented on GitHub (Oct 24, 2017):
See https://github.com/doctrine/doctrine2/tree/master/tests/Doctrine/Tests/ORM/Functional/Ticket for examples on how to construct tests inside the context of the ORM project.
@jigarpancholi commented on GitHub (Oct 24, 2017):
I just found same issue what I am facing here https://github.com/everlutionsk/EmailBundle2/issues/13.
@apoorva-shah commented on GitHub (Oct 24, 2017):
Yes @jigarpancholi I also have same issue. Did not understand what to do. @Ocramius I think thats bug in doctrine.
@Ocramius commented on GitHub (Oct 24, 2017):
That's exactly the difference between opinion and proof. Without a test, nobody can really verify nor work on the issue at all.
@stephenheron commented on GitHub (Oct 29, 2017):
I think this might be the same issue as: https://github.com/doctrine/doctrine2/issues/6565
@jigarpancholi commented on GitHub (Oct 31, 2017):
Yes, this issue is only for MriaDB not for MySql.
@belgattitude commented on GitHub (Nov 4, 2017):
Should be fixed with https://github.com/doctrine/dbal/pull/2825
@lcobucci commented on GitHub (Nov 26, 2017):
Closing as
Invalidsince it's DBAL issue and should be already fixed when usingv2.7.x-devversion ofdoctrine/dbal.@Glideh commented on GitHub (Apr 25, 2018):
Seems not. I was having this issue with a brand new SF4 installation (and MariaDB 10.2.14).
I upgraded dbal:
Checking the diffs:
Executing them:
Re-checking:
Those fields are indeed defined as
nullable=trueandNULLis indeed already allowed in the database.@strawburrypokki commented on GitHub (Apr 25, 2018):
I don't know if it is related or not, but try checking https://github.com/doctrine/doctrine2/issues/6565.
It seems the issues is still there (https://github.com/doctrine/doctrine2/issues/6565#issuecomment-379290175)
@Glideh commented on GitHub (Apr 25, 2018):
Well that was my +1 on this comment you are linking :)
@strawburrypokki commented on GitHub (Apr 25, 2018):
Oh, sorry! I didn't notice :)
@belgattitude commented on GitHub (Apr 25, 2018):
@Glideh
Don't remember exactly but from dbal perspective I'm pretty sure it's working as intended...
In other words, using the dbal command should work
For the symfony part, I cannot tell... But one thing I can think of, is:
If you are NOT relying on server version autodetection, and have
server_versionparam set somewhere in your symfonoy app. THEN be sure you set it greater than 10.2.7 (please include the bugfix number '.14' in your example or greater) or remove the key from your config.This should do the trick.... but I cannot help from symfony side, never had the chance to use it.
PS: The information change have appeared in 10.2.7 (10.2.6 was already GA)... I've made the mariadb 10.2: https://github.com/doctrine/dbal/pull/2825, but from the discussion it was important to make it 10.2.7 instead of 10.2... Not that I'm happy with it
@Glideh commented on GitHub (Apr 25, 2018):
I'm actually using migrations but giving the example with
doctrine:schema:update(d:s:u) to simplify (which is used bymigration:diffbehind the scenes isn't it ?).Each
doctrine:migrations:diffwill always add theDEFAULT NULLalterations.My server version was initially set to
10.2, I had tried removing it before without any effect, I just tried setting it to10.2.14with no more effect (container rebuilt to make sure it is not a cache issue)@belgattitude commented on GitHub (Apr 26, 2018):
@Glideh
just to be se sure... I didn't understand:
Means the issue is fixed or not ?
@belgattitude commented on GitHub (Apr 26, 2018):
@Glideh, if the issue is not fixed with the server version...
Can you copy/paste your example entities ? So I can try too... because I still cannot reproduce with mine.
Thank you
@belgattitude commented on GitHub (Apr 26, 2018):
@Glideh
I think yes but I don't know details, I'm using:
@Glideh commented on GitHub (Apr 26, 2018):
Ok I'll try to make a reproducible example
@belgattitude commented on GitHub (Apr 26, 2018):
@Glideh don't worry about giving something perfect, I'll handle... you can just provide what you used for your examples
It's fine for me
@Glideh commented on GitHub (Apr 26, 2018):
I wanted to give you a nice docker setup but I didn't manage to do it quickly.
So here is an entity that causes a systematic diff.
The diff is only in the nullable field
For info my doctrine versions requirements:
@belgattitude commented on GitHub (Apr 27, 2018):
Still cannot reproduce... but I feel we can sort things out ;)
On my setup, running
./vendor/bin/doctrine orm:schema-tool:update --dump-sql, givesThen I run
./vendor/bin/doctrine orm:schema-tool:update --force... All ok, from here I have a schema with the latests changes.Running migrations gives nothing (my schema is up to date as expected), for example:
To be exactly sure... I've setup a travis build to check the behaviour.. See https://travis-ci.org/belgattitude/openstore-schema-core and the used travis file https://github.com/belgattitude/openstore-schema-core/blob/master/.travis.yml.
So on my side, I cannot reproduce with my setup. So to exclude more case, can you run the following sql
For my setup it gives
What's your output ?
PS: if you're wondering I've put Question.php entity in https://github.com/belgattitude/openstore-schema-core/tree/master/tests/entity
@Glideh commented on GitHub (Apr 27, 2018):
I seem to have the same as expected, my database is well in sync too, the issue is in the diff (
update --dump-sql). If I ask a diff again to Doctrine, it will think the DEFAULT NULL are missing.@belgattitude commented on GitHub (Apr 27, 2018):
Also, just to be sure .. force dbal version in your composer.json
@Glideh commented on GitHub (Apr 27, 2018):
Already done in my first comment
Same result
@belgattitude commented on GitHub (Apr 27, 2018):
Hey @Glideh,
just noticed from your sql output that 'question' table is without uppercase:
Not sure, but can you try to add with capitalization:
@belgattitude commented on GitHub (Apr 27, 2018):
Alos noticed a difference, probably not important: but let's try...
Looking at your output:
The fifth column seems weird to me, the first row have 9 columns, the next ones have 10 cols... Can you recheck the output of the SQL ?
@Glideh commented on GitHub (Apr 27, 2018):
Ho but I'm noticing something, when I copy/pasted the query result from my db client, I reworked it manually (which also explains the missing pipe) to replace the empty spaces by
NULLbut I didn't see there was already some NULL values. Let's do a screenshot to illustrate.I added a nullable int
theme_idto compare. The differentNULLand<null>values seems especially weird to me on this field, isn't it ?@belgattitude commented on GitHub (Apr 27, 2018):
no it's the way new Mariadb treats null. got to go now but I'll look deeper on Sunday our Monday. thanks for the screenshot
@belgattitude commented on GitHub (Apr 27, 2018):
maybe try to set the charset in the entity. check an example in the openstore-schema-core repo. I'm on mobile., ill let you find the link 😀I'm not sure the problem comes from null default
@Glideh commented on GitHub (Apr 27, 2018):
My Doctrine diffs always concern exclusively nullable fields.
My whole model currently contains about 50 fields, I have 12 nullable, they are all appearing in the diff.
I'll try to set the charset on an entity.
@belgattitude commented on GitHub (Apr 27, 2018):
yes please try. even if it's not working I can look somewhere else.
@belgattitude commented on GitHub (Apr 29, 2018):
@Glideh I'm back on it... Sorry for redundancy but I try to put the pieces together. So as far as I found , here's some related issues that I'll link here:
For now I'm still unable to reproduce your case... for reference see
https://github.com/belgattitude/openstore-schema-core/blob/master/.travis.yml
https://github.com/belgattitude/openstore-schema-core/tree/master/tests/entity
https://travis-ci.org/belgattitude/openstore-schema-core
Would be really nice when you have time to retest with this updated entity:
I would like to exclude possible charsets or mariadb configuration differences... It might not help but good for me.
In the meantime, I'll try to test with symfony with the test repo created by @Bukashk0zzz. As I'm not used to symfony any help is appreciated (https://github.com/belgattitude/dbal-test). /ping @musicgerm
Also would be nice to have your doctrine.yaml config
@belgattitude commented on GitHub (Apr 29, 2018):
@Glideh sorry for long texts :)
Just tested with symfony:
https://github.com/belgattitude/dbal-test/tree/doctrine2/6790
And seems it works too:
https://travis-ci.org/belgattitude/dbal-test
If you see anything in the config that can explain let me know.
@Glideh commented on GitHub (Apr 29, 2018):
Thank you for your time @belgattitude, I'll check that and keep you in touch as soon as I find some.
@belgattitude commented on GitHub (May 1, 2018):
@Glideh , just a free thought... do you use/have migrations classes ? I can imagine problems with it... If it's that, I think I can look into this... All the best
@Glideh commented on GitHub (May 1, 2018):
I have a migration class, but I also tried without, same result.
@belgattitude commented on GitHub (May 1, 2018):
It would have been nice ;) Anyway, we'll figure it out. In case, you can always test with https://github.com/belgattitude/dbal-test/tree/doctrine2/6790... You don't need docker (
./up.sh), just clone and checkout branch (git checkout -b doctrine2/6790), composer install and set the correct db credentials in.env... From there you can add new entities and use the doctrine commands as usual.@Glideh commented on GitHub (May 1, 2018):
Nice setup, thank you.
I always use composer from within a container so I don't have it installed in my computers (same for php).
I have Docker on all of them though (If I could have it in my phone and tablets I would be happy :), so I'm using your
up.sh.jakubsacha/symfony-dockerimage is taking some time (I have a bad connection), I used themariadb:10.2I already had though (10.2.14) instead of10.3which you had.@Glideh commented on GitHub (May 1, 2018):
Composer seems included into the image but not git, so I can't install the dependencies with it.
Also
up.shcomplains about/var/www/html/varnot existing when runningchmod.@belgattitude commented on GitHub (May 1, 2018):
Possible, I haven't tested with docker... but if you have a working docker image running, just clone into it for a test.
@belgattitude commented on GitHub (Jun 11, 2018):
@Glideh I know it's long time... But I got a possible answer.
It should work if you set
server_version: 'mariadb-10.2.15'(withmariadb-prefix) or if you don't specify server_version at all (in this case it will be autodetected)See https://github.com/doctrine/doctrine2/issues/7258#issuecomment-396359632
@Glideh commented on GitHub (Jun 12, 2018):
Thx, I'll try that
@justinas-kazanavicius commented on GitHub (Jul 5, 2018):
@belgattitude It works for my application! Thanks!
@4cc355-d3n13d commented on GitHub (Sep 8, 2018):
Seen the same on mysql db, few projects!
@4cc355-d3n13d commented on GitHub (Sep 8, 2018):
One of the queries, executes every run of schema update:
ALTER TABLE meta_currency CHANGE code code VARCHAR(6) NOT NULL;@JKetelaar commented on GitHub (Oct 2, 2019):
Just had the same issue, my way to solve this was setting the server version in
config/packages/doctrine.yml.From
To