I’m working the “proper way” with creating the initial db schema via
migrations and db/schema.rb.
However, I have a bit of a special need, and need to know if anyone
knows the solution to this;
I need a sequence that is common to several tables - a “data id” that
gives a sort of unique object number to every row in every table. Some
associated tables (a documents table that can contain attachments to
most any model to be exact) need this id as their foreign key
create_table “projects”, :force => true do |t|
t.column “data_id”, :serial t.column “parent_id”, :int
t.column “customer_id”, :int
t.column “property_owner_id”, :int
t.column “name”, :string
t.column “long_description”, :text
t.column “created”, :datetime
Now, I’ve done this all wrong, I know. The data_id field represented
here creates a new sequence for each table, in this case named
“projects_data_id_seq”. I need all tables to use the same, preexisting
Do I need to specify the sql for this? Can anybody help me?
mopo: økt frihet? gjennom fri programvare!