Forum: Ruby on Rails Migrations - How to set auto increment?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Vamsee (Guest)
on 2006-02-28 00:21
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.
Vamsee (Guest)
on 2006-02-28 00:26
Sorry, I forgot to tell you that I want auto increment for a field other
than the primary key (id).
Anthony DeRobertis (Guest)
on 2006-02-28 17:50
(Received via mailing list)
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.
This topic is locked and can not be replied to.