You can but you will loose portability. Use columnDefinition attribute and set it to integer unsigned. The actual code depends on what you are using.
columnDefinition: DDL SQL snippet that starts after the column name
and specifies the complete (non-portable!) column definition. This
attribute allows to make use of advanced RMDBS features. However you
should make careful use of this feature and the consequences.
SchemaTool will not detect changes on the column correctly anymore if
you use “columnDefinition”.
Checkout a full writeup on why here. [EDIT](link does not work) I have pasted the article below. It was written by me anyways ;)
unsigned numbers so large your brain will explode! w/Doctrine 2
ORMs have an inherent problem. How do you take a datatype only some RDBMSs support and allow you to use it anyways. Well when it comes to Doctrine 2 and unsigned numbers they got a little lazy.
All I want to do is store my 64bit facebook IDs. How hard is that? Well my RDBMS is mySQL so all I really need is an unsigned bigint.
columnDefinition: DDL SQL snippet that starts after the column name and specifies the complete (non-portable!) column definition. This attribute allows to make use of advanced RMDBS features. However you should make careful use of this feature and the consequences. SchemaTool will not detect changes on the column correctly anymore if you use “columnDefinition”.
Basically this feature let’s you free form unsupported things into the column definition. Making unsigned numbers technically UN-SUPPORTED! Not to mention my dev and QA deployment systems rely heavily on the SchemaTool. We can thank a combination of lazy developers at Doctrine and sqlite3 for this little nugget of crazy town.
This immediately prompted a google search. I don’t like thinking if I don’t have to. What did I find? Everybody’s using varchars. VARCHARS!?!? I about had a heart attack. That was just unacceptable.
Thus enters decimal. It’s perfect. The storage size is variable and it’s stored in binary so indexing is super fast. We just set the decimal precision to zero and voilà. The ORM can port this to any RDBMS, it’s big enough for us not to care about the unsupported signed/unsigned issue and it’s lightning fast. decimal(20,0) should handle our facebook size of eighteen quintillion four hundred and forty six quadrillion seven hundred and forty four trillion seventy three billion seven hundred and nine million five hundred and fifty one thousand six hundred and fifteen quite nicely.
Running diff migration bin/console doctrine:migration:diff will do some magic.In fact, if the column was a foreign key in other tables, the doctrine is able to find them out and apply the same update row as the concerned column.
You just need in your migration to remove foreign keys before and add them after the column type transformation.