简体   繁体   中英

Symfony2 Doctrine2 Oracle database NUMBER DEFAULT type?

I have a problem, I migrated an application from Symfony 1.4 to Symfony 2.4. I had some troubles getting a decimal variable working. I ended up updating the database with another type but now that I have to use the old production Oracle Database, Doctrine2 tells me I cannot update a field type if there is data in it.

The data it stores is 0.1 or 0.5 or 1.0

In Oracle, the DATA_TYPE is "NUMBER"

    CREATE TABLE "APPRENTICE"."APPRENTICE_YEARTYPE" 
   (    "ID" NUMBER(20,0), 
    "NAME" VARCHAR2(255 BYTE), 
    "ROUNDNUMBER" NUMBER DEFAULT NULL
   ) SEGMENT CREATION IMMEDIATE

When I export the old database with the Symfony2 command, the datatype in Doctrine is Integer... I cannot have decimals with an int. When I try to change the type to decimal with a scale of 2, I get the error that I cannot change the type.

The generated Doctrine2 code :

/**
 * @var integer
 *
 * @ORM\Column(name="ROUNDNUMBER", type="integer", nullable=false)
 */
private $roundnumber;

The Doctrine1 schema :

ApprenticeYeartype:
  columns:
    id:                  {type: integer, notnull: true, primary: true, autoincrement: true}
    name:                {type: string(255), notnull: true}
    roundNumber:         {type: float, notnull: true}

If I try to set the Doctrine2 value to float and update, I get the following error :

 [Doctrine\DBAL\DBALException]
 An exception occurred while executing 'ALTER TABLE APPRENTICE_YEARTYPE MODI
 FY (ROUNDNUMBER  DOUBLE PRECISION DEFAULT NULL)':

 ORA-01440: column to be modified must be empty to decrease precision or sca
 le






 [Doctrine\DBAL\Driver\OCI8\OCI8Exception]
 ORA-01440: column to be modified must be empty to decrease precision or sca
 le

I'm stuck with this, anyone can help ?

Regards

Finally, I changed the Doctrine type to "Decimal, precision 2, scale 1'.

I manually updated the Oracle type to NUMBER(2,1).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM