views:

120

answers:

2

The title says it all.

I want to set the start value for auto increment on a column to 1000000 (to avoid conflicts with a legacy application), but can't find any documentation that tells me how.

Pretty standard table, here's what the relevant bit looks like:

User:   
  attributes:
    export: tables
  columns: 
    id:
     type: integer
     primary: true
     autoincrement: true
    code:
     type: string(6)
...
A: 

Here are some thoughts since there seems no other way.

Can you set the default value of id to be 100000? I haven't tried this, but it might work.

Another option would be to have your install script insert a row with a id value of 100000. If necessary, it could remove it as well. This would move the autoincrement up to 100000.

Justin Giboney
Negative on both counts. I tried adding default: 1000000 to the id field and rows were still inserted starting at 1. I also tried adding a row with id 1000000 and removed it, and new entries started at 1.Good ideas though.
Peter
+1  A: 

The best way to acomplish this would be the creation of a Doctrine Migration. There you are able to set the value of the sequence table to the value you want. Migrations are easy to use (http://www.doctrine-project.org/projects/orm/1.2/docs/manual/migrations/en#migrations) and you can run it during your deployment process of your application.

Timo
That sounds like the way to go, thanks.
Peter