Create missing auto increment attribute with rails migration

前端 未结 3 1557
攒了一身酷
攒了一身酷 2020-12-19 02:40

I\'m writing a migration to convert a non-rails app into the right format for rails - one of the tables for some reason does not have auto increment set on the id column. I

3条回答
  •  悲&欢浪女
    2020-12-19 03:20

    The Postgres answer by @jlfenaux misses out on the serial type, which does all of it for you automatically:

    ALTER TABLE tbl add tbl_id serial;
    

    More details in this related answer.

提交回复
热议问题