Skip to content
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

Migration diff command always add migration for default values of custom type fields #2506

Closed
josecelano opened this issue Sep 15, 2016 · 5 comments

Comments

@josecelano
Copy link

Hi. I have the problem described here:

http://stackoverflow.com/a/27557785/3012842

Basically when I use a custom DBAL type like CarbonDateTimeType doctrine always creates a migration for changing the default value of that field.

The migration looks like:

$this->addSql('ALTER TABLE table_name CHANGE field_with_carbon_date_time_type field_with_carbon_date_time_type DATETIME NOT NULL');

In stackoverflow @vbence says it's a bug but the link is to the old jira bug tracker. And I do not know if th bug is fixed or how can I fix it. The solution in stackoverflow is not valid in this case because that type already contains the method requiresSQLCommentHint

Thanks.

@josecelano
Copy link
Author

I have found the solution in this blog post from @ricbra:

https://blog.vandenbrand.org/2015/06/25/creating-a-custom-doctrine-dbal-type-the-right-way/

You have to add this comment: (DC2Type:CarbonDateTime) to the field in the table which is mapped to the custom type. Where CarbonDateTime is the custom type.

This is the sample SQL to add that comment:

ALTER TABLE `table_name`
    CHANGE COLUMN `table_field` `table_field` DATETIME NOT NULL COMMENT '(DC2Type:CarbonDateTime);

Then, I suppose this is not a bug in this package and I should open an issue in beberlei/DoctrineExtensions.

Maybe they should add this code:

    /**
     * @param array            $fieldDeclaration
     * @param AbstractPlatform $platform
     * @return string
     */
    public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
    {
        return sprintf('BINARY(%d) COMMENT \'(DC2Type:uuid)\'', $fieldDeclaration['length']);
    }

into their CarbonDateTimeType class.

Is that correct?

@vbence
Copy link

vbence commented Sep 15, 2016

Hi, the issue imported form Jira can be found here:
#1137

@deeky666
Copy link
Member

@josecelano maybe realted to #2594
Please try again with current master and report back. Thanks.

@morozov
Copy link
Member

morozov commented Aug 5, 2022

Closing due to the lack of feedback. Likely, irrelevant as of #5512.

@morozov morozov closed this as not planned Won't fix, can't repro, duplicate, stale Aug 5, 2022
@github-actions
Copy link

github-actions bot commented Sep 5, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants