Forum: Ruby on Rails No sequence is needed

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.
Sijo k. (Guest)
on 2009-02-05 08:04
Hi
    I would like to know how can i generate a model, without generating
the sequence table in postgresql..Currently for example when I do

def self.up
create_table :table1 do |t|
--------

     A sequence is automatically generated like tables_id_seq

Thanks in advance
Sijo
Robert W. (Guest)
on 2009-02-05 17:36
Sijo Kg wrote:
> Hi
>     I would like to know how can i generate a model, without generating
> the sequence table in postgresql..Currently for example when I do
>
> def self.up
> create_table :table1 do |t|
> --------
>
>      A sequence is automatically generated like tables_id_seq
>
> Thanks in advance
> Sijo

This can be done by using the :id => false option:
create_table :users, :id => false do |t|

However, I would highly recommend against doing this. With a few
exceptions. The primary one being join tables that use a compound
primary key composed of two foreign keys.

One important aspect of an ORM system like ActiveRecord is to have clear
object identity. I do everything I can to avoid using natural primary
keys, and I have VERY strong opinions about tables laking a primary key.

For a comprehensive overview that lines up nicely with my opinions here
is a well written article:
http://rapidapplicationdevelopment.blogspot.com/20...
This topic is locked and can not be replied to.