3

I am attempting to create a table in rails.. I need to be able to set the id's to data that's coming in because I have three (or more) sources, and their ID's must match.
I'm setting the ID's manually, based on data I get in.

When I create the table with a migration, I get the message "will create implicit sequence" I don't want this to happen... How do I avoid it?

I know why it's always there.. but sometimes we need customization no? :)

baash05
  • 4,394
  • 11
  • 59
  • 97
  • Please, read this [link](http://stackoverflow.com/questions/5296290/notices-for-sequence-after-running-migration-in-rails-on-postgresql-application) – Victor Rodrigues Mar 27 '12 at 01:46

1 Answers1

5

ActiveRecord make the :primary_key column auto_increment by default. Maybe you have to create the primary key by yourself if you don't want it auto_increment.

create_table :table_name, :id => false do |t|
  t.integer :id
  t.timestamps
end
ActiveRecord::Base.connection.execute("ALTER TABLE table_name ADD PRIMARY KEY (id)")
Yanhao
  • 5,264
  • 1
  • 22
  • 15