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

Generated columns added to migrations file every time - any way to tell the migration to ignore single fields? #490

Open
gravitiq-cm opened this issue Mar 1, 2023 · 2 comments

Comments

@gravitiq-cm
Copy link

I have a generated column in my entity

/**
 * @ORM\Column(type="boolean", columnDefinition="TINYINT(1) GENERATED ALWAYS AS (xyz) STORED", insertable=false, updatable=false)
 * @ORM\Ignore()
 */

This works fine. However, every time I run make:migration (even with no new changes) a new migration file is created with the details of the generated columns. E.g. something like this:

        $this->addSql('ALTER TABLE my_table ADD my_field TINYINT(1) GENERATED ALWAYS AS (xyz) STORED');

I guess this is because the migration diff cannot see details of the generated column?

Is there any way to
a) see/debug what the migration is comparing to what (to see if I just need to tweak the text in the columnDefinition)
b) to mark the generated column as "ignore during migration" so make:migration does not consider it when creating migrations
?

@gravitiq-cm
Copy link
Author

Update: I tried to do some debugging in Doctrine\DBAL\Schema\Comparator but it seems there's no data about the generated field pulled from the database.

In the short term, is there a way to mark this column as excluded from consideration when calculating the migration diff?

@armellin
Copy link

Is there any update about this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants