Comments (8)
Did I do something wrong?
No, you didn't. I didn't changed the column definition in code, so basicly it creates a default datetime column. Of course, I haven't checked that, it is only my feeling. I could have check that in detail but, I don't think I could have do that in the next few days.
Additionally I think that it's worth to add a doctrine configuration section to readme, because to make microseconds work correctly you have to register a custom type in doctrine.yaml config file
I will add that in the next release.
If you will find solution of the first problem, feel free to do the Pull Request.
from doctrine-datetime-with-microseconds.
I guess I found a solution. It was indeed the getSQLDeclaration
method. I will write some tests and then I can make PR. Probably tomorrow.
from doctrine-datetime-with-microseconds.
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
$parentDateTimeDeclaration = $platform->getDateTimeTypeDeclarationSQL($fieldDeclaration);
if ($platform instanceof SqlitePlatform) {
$precision = 3;
} else {
$precision = 6;
}
return preg_replace('/(DATETIME[2]?|TIMESTAMP)(\([0-9]{1,2}\))?/', '$1('.$precision.')', $parentDateTimeDeclaration);
}
It's my solution above. Main idea is to use string returned by Doctrine and then just change the precision of field type. It may not work for older DB engines which don't provide support for microseconds.
I didn't create a PR as there is one more problem with it. I don't know why, but Symfony still create a following migration
ALTER TABLE table CHANGE created_date created_date DATETIME(6) NOT NULL
even if that field in my DB has got exactly that type.
from doctrine-datetime-with-microseconds.
I don't know why, but Symfony still create a following migration
ALTER TABLE table CHANGE created_date created_date DATETIME(6) NOT NULL
I don't get it. Why do you think it is a problem? What do you expect?
from doctrine-datetime-with-microseconds.
The migration is created each time you run bin/console make:migration
even if there is no such need.
- run
bin/console make:migration
on empty DB or newly created field - run
bin/console doctrine:migrations:migrate
- run
bin/console make:migration
In step 3 there shouldn't be anything to migrate as you updated your DB's schema in step 2.
I need to check make:migration
command to verify how it compares actual DB schema with provided entity field type.
from doctrine-datetime-with-microseconds.
Ok, now I get it. Have you tried to clear cache? You did change the schema outside the doctrine, so maybe it tries to change the schema, because it doesn't see changes.
from doctrine-datetime-with-microseconds.
Just read your message again, and now I understand. There is for sure, a problem with diff mechanism. I don't know how it works either, but I think it is very interesting. Let me know if you need any help. I will try to solve it either.
from doctrine-datetime-with-microseconds.
That method have to be overridden, too.
public function requiresSQLCommentHint(AbstractPlatform $platform)
{
return true;
}
Then a new migration should add a comment to the DB field with custom type name like that
COMMENT \'(DC2Type:datetime_microseconds)\'
You may take a look here
Please note that I also changed SQL declaration to $platform->getDateTimeTypeDeclarationSQL
There was DateTimeTz
before but I think that datetime_microseconds
shouldn't use it as it's for datetimetz
field type.
from doctrine-datetime-with-microseconds.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from doctrine-datetime-with-microseconds.