Migrations - How to set auto increment?


#1

Hi all,

I’d like to know how can I set a field to auto increment in migrate
scripts. In mysql, it’s auto_increment, and in postgresql, it’s serial.
How can I make a migrate script which works in both places?

TIA,
Vamsee.


#2

Sorry, I forgot to tell you that I want auto increment for a field other
than the primary key (id).


#3

Vamsee wrote:

Sorry, I forgot to tell you that I want auto increment for a field
other than the primary key (id).

mysql> create table test (
a int auto_increment primary key,
b int unique auto_increment
);
ERROR 1075: Incorrect table definition; There can only be one auto
column and it must be defined as a key

MySQL doesn’t seem able.