Rockking
Rockking

Reputation: 215

how to apply autoincrementation in rails 3.2

I was doing a shopping list project in ruby on rails. While creating the table named products, by mistake I have removed the autoincrement option from id field of my table products.

Can any one tell me ,how can I reinsert the option of autoincrement in table through migration.

my product table is as follows:-

  id serial NOT NULL,
  shopping_list_id integer NOT NULL,
  product_name character varying(255) DEFAULT 'null'::character varying,
  product_category character varying(255),
  quantity integer,
  status character varying(255) DEFAULT 'OPEN'::character varying,
  deleted integer NOT NULL DEFAULT 0,
  CONSTRAINT products_pkey PRIMARY KEY (id)

my product table is referencing my shopping_list table.

I am using Postgresql database.

Upvotes: 1

Views: 74

Answers (1)

sjain
sjain

Reputation: 23344

Although you can do by simply executing the SQL statements, but for Postgresql users you need to create a new sequence in the database.

This is mentioned in this SO post.

Upvotes: 1

Related Questions