-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doctrine schema update command shows always few queries to be executed #6790
Comments
This needs a test case to validate why this is happening. |
@Ocramius do I need to create test case for that? |
@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. |
@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. |
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. |
I just found same issue what I am facing here everlutionsk/email-bundle-2#13. |
Yes @jigarpancholi I also have same issue. Did not understand what to do. @Ocramius I think thats bug in doctrine. |
That's exactly the difference between opinion and proof. Without a test, nobody can really verify nor work on the issue at all. |
I think this might be the same issue as: #6565 |
Yes, this issue is only for MriaDB not for MySql. |
Should be fixed with doctrine/dbal#2825 |
Closing as |
Seems not. I was having this issue with a brand new SF4 installation (and MariaDB 10.2.14).
Checking the diffs:
Executing them:
Re-checking:
Those fields are indeed defined as |
I don't know if it is related or not, but try checking #6565. |
Well that was my +1 on this comment you are linking :) |
Oh, sorry! I didn't notice :) |
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 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: doctrine/dbal#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 |
I'm actually using migrations but giving the example with Each My server version was initially set to |
just to be se sure... I didn't understand:
Means the issue is fixed or not ? |
@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 |
I think yes but I don't know details, I'm using:
|
Ok I'll try to make a reproducible example |
@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 |
I wanted to give you a nice docker setup but I didn't manage to do it quickly. namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class Question
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string")
*/
private $label;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $complement;
} The diff is only in the nullable field
For info my doctrine versions requirements: "doctrine/doctrine-bundle": "^1.9",
"doctrine/doctrine-migrations-bundle": "^1.3",
"doctrine/orm": "^2.6", |
Still cannot reproduce... but I feel we can sort things out ;) On my setup, running CREATE TABLE Question (id INT AUTO_INCREMENT NOT NULL, label VARCHAR(255) NOT NULL, complement VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB; Then I run 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 SELECT `TABLE_SCHEMA`,
`TABLE_NAME`,
`COLUMN_NAME`,
`COLUMN_DEFAULT`,
`IS_NULLABLE`,
`DATA_TYPE`,
`CHARACTER_MAXIMUM_LENGTH`,
`CHARACTER_SET_NAME`,
`COLLATION_NAME`
FROM `information_schema`.`COLUMNS`
WHERE `TABLE_NAME` = 'Question'
ORDER BY `ORDINAL_POSITION` ASC 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 |
Already done in my first comment
Same result |
Hey @Glideh, just noticed from your sql output that 'question' table is without uppercase:
Not sure, but can you try to add with capitalization:
|
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 ? |
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 I added a nullable int |
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 |
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 |
My Doctrine diffs always concern exclusively nullable fields. |
yes please try. even if it's not working I can look somewhere else. |
@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 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 |
@Glideh sorry for long texts :) Just tested with symfony: If you see anything in the config that can explain let me know. |
Thank you for your time @belgattitude, I'll check that and keep you in touch as soon as I find some. |
@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 |
I have a migration class, but I also tried without, same result. |
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 ( |
Nice setup, thank you. |
Composer seems included into the image but not git, so I can't install the dependencies with it. |
Possible, I haven't tested with docker... but if you have a working docker image running, just clone into it for a test. |
@Glideh I know it's long time... But I got a possible answer. It should work if you set See #7258 (comment) |
Thx, I'll try that |
@belgattitude It works for my application! Thanks! |
Seen the same on mysql db, few projects! |
One of the queries, executes every run of schema update:
|
To avoid changes in INT fields doctrine/orm#6790
Just had the same issue, my way to solve this was setting the server version in From
To
|
I am using doctrine with symfony and run
php bin/console doctrine:schema:update --force
command. 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;
The text was updated successfully, but these errors were encountered: