Reputation: 1346
In my schema I have a number of field that need to be BIGINT
. I use the following command from Symfony
symfony doctrine:build-sql
to generate my database. The fields always come out as type int
. I have tried the following types in the schema:
int
{type: integer, notnull: true}
{type: integer(5), notnull: true}
{type: bigint, notnull: true}
None of them seem to work (I always rebuild the model before building the SQL).
What type should i put in the schema.yml
?
Upvotes: 4
Views: 21977
Reputation: 4567
With Symfony 2.x (e.g. Doctrine 2.4.1) and PHP annotations on Entities, using @ORM\Column(name="id", type="bigint")
results in a MySQL bigint(20)
.
NB: OP tagged this question with symfony1 & doctrine1, for which this solution will not work.
Upvotes: 19
Reputation: 574
yes, integer(5) should do the work.
You can check other schema data types in The symfony and Doctrine book, but have in mind that it's version 1.2 and it's not maintained anymore.
Best regards.
Upvotes: 0
Reputation: 23255
It depends on your RDBMS, but if you use MySQL, you can read lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/DataDict/Mysql.php
case 'integer':
case 'int':
if ( ! empty($field['length'])) {
$length = $field['length'];
if ($length <= 1) {
return 'TINYINT';
} elseif ($length == 2) {
return 'SMALLINT';
} elseif ($length == 3) {
return 'MEDIUMINT';
} elseif ($length == 4) {
return 'INT';
} elseif ($length > 4) {
return 'BIGINT';
}
}
return 'INT';
so your second attempt should have worked... or do you use another RDBMS? You should set a breakpoint at this line of code and do step-by-step debugging, this is strange. Also, check the content of your Mysql.php file to see if you have the same thing as me (I use the doctrine shipped with sf 1.4.11)
Upvotes: 6