How to get the doctrine for generating sql with type BIGINT?

In my schema, I have several fields that should be BIGINT. I am using symfony's

symfony doctrine:build-sql

to create my database.

Fields always exit as int.

I tried the following types in the schema:

int

{type: integer, notnull: true}

{type: integer(5), notnull: true}

{type: bigint, notnull: true}

None of them work (I always rebuild the model before building SQL).

What type should I add to schema.yml?

+3
source share
3 answers

With Symfony 2.x (e.g., Doctrine 2.4.1) and PHP annotations on Entities using @ORM\Column(name="id", type="bigint"), it turns out MySQL bigint(20).

NB: OP noted this question with symfony1 and doctrine1, for which this solution will not work .

+14
source

, MySQL, 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';

... ? , . , Mysql.php, , , ( , sf 1.4.11)

+5

, (5) .

Symfony Doctrine, , 1.2, .

.

0

All Articles