We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I have a custom type
final class DateTimeImmutableMicrosecondsType extends DateTimeTzImmutableType { private const FORMAT = 'Y-m-d H:i:s.u'; /** * @param T $value * * @return (T is null ? null : string) * * @throws ConversionException * * @template T */ public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): ?string { if ( $value instanceof DateTimeImmutable && $platform instanceof PostgreSQLPlatform ) { return $value->format(self::FORMAT); } return parent::convertToDatabaseValue($value, $platform); } /** * @param T $value * * @return (T is null ? null : DateTimeImmutable) * * @template T * @throws InvalidFormat */ public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?DateTimeImmutable { if ($value === null || $value instanceof DateTimeImmutable) { return $value; } if ($platform instanceof PostgreSQLPlatform) { try { $dateTime = DateTimeImmutable::createFromFormat(self::FORMAT, $value); } catch (\Throwable) { throw InvalidFormat::new( $value, self::class, $platform->getDateTimeTzFormatString(), ); } if ($dateTime !== false) { return $dateTime; } throw InvalidFormat::new( $value, self::class, $platform->getDateTimeTzFormatString(), ); } return parent::convertToPHPValue($value, $platform); } /** @param mixed[] $column */ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { if ($platform instanceof PostgreSQLPlatform) { return 'TIMESTAMP(6) WITH TIME ZONE'; } return $platform->getDateTimeTzTypeDeclarationSQL($column); } }
in my Symfony app it registered like this
doctrine: dbal: types: datetimetz_immutable: App\Doctrine\Types\DateTimeImmutableMicrosecondsType
and in my XML entity mapping, I use it like this
<field name="updatedAt" type="datetimetz_immutable" column="updated_at" nullable="true"/>
All worked perfectly, diff command generated migration like this:
updated_at TIMESTAMP(6) WITH TIME ZONE
and added commend like this
'COMMENT ON COLUMN updated_at IS \'(DC2Type:datetimetz_immutable)\''
But now I updated DDBAL to version 4.2.1 and when I run a diff it generates a new migration
$this->addSql('ALTER TABLE table ALTER updated_at TYPE TIMESTAMP(6) WITH TIME ZONE'); $this->addSql('COMMENT ON COLUMN updated_at IS \'\'');
First of all for some reason removing comment, and altering table to set same type again :)
Okay, I run that migration and run diff again and it generate migration like this
$this->addSql('ALTER TABLE table ALTER updated_at TYPE TIMESTAMP(6) WITH TIME ZONE');
So it's always trying to convert type to TIMESTAMP(6) WITH TIME ZONE but that type is already correct one.
TIMESTAMP(6) WITH TIME ZONE
Doctrime diff always generating migration like this
Have a custom type from above, dbal 4.2.1 and run diff command
The text was updated successfully, but these errors were encountered:
Duplicate of #1441.
Sorry, something went wrong.
No branches or pull requests
Bug Report
Summary
I have a custom type
in my Symfony app it registered like this
and in my XML entity mapping, I use it like this
All worked perfectly, diff command generated migration like this:
and added commend like this
But now I updated DDBAL to version 4.2.1 and when I run a diff it generates a new migration
First of all for some reason removing comment, and altering table to set same type again :)
Okay, I run that migration and run diff again and it generate migration like this
So it's always trying to convert type to
TIMESTAMP(6) WITH TIME ZONE
but that type is already correct one.Current behavior
Doctrime diff always generating migration like this
How to reproduce
Have a custom type from above, dbal 4.2.1 and run diff command
The text was updated successfully, but these errors were encountered: