Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove the implicit SEQUENCE on ID field?

I've seen we can avoid using a SEQUENCE on the object's ID by doing this:

create_table :table_name, :id => false do |t|
  t.integer :id
  t.timestamps
end

But, if my table is already created and I want to remove the "CREATE SEQUENCE table_name_id_seq" from the schema, how can I do this without dropping the table? If impossible it will be ok I guess but I did not want to loose my table content.

like image 750
code-gijoe Avatar asked Sep 04 '25 16:09

code-gijoe


1 Answers

You'll have to use raw SQL to do this. Something like the following:

def up
  ActiveRecord::Base.connection.execute "DROP SEQUENCE table_name_id_seq"
end

http://www.postgresql.org/docs/9.1/static/sql-dropsequence.html

like image 166
Jeff Dickey Avatar answered Sep 07 '25 12:09

Jeff Dickey