Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Problem with 2.3.4, habtm and Slony Replication on Postgresql, related to #2086

#3206

As of 2.3.4 rails now raises an exception when habtm table contains a primary key (see #2086 Primary key on HABTM join table now raises an exception).

However, on Postgresql, when used with Slony Replication (which is a most popular replication tool), you have to have primary key in order to replicate the table. While you can make a composite key on habtm table, one of the options is to add a synthetic primary key to the table, which was a standard approach with Slony for quite some time now. This is what I had in my setup - multiple replications set up on all of my applications with synthetic keys for all habtm tables.

After upgrading to 2.3.4, they have all failed and I had to manually edit has_and_belongs_to_many_association.rb to comment out lines 42-45 to disable the check.

Now, while it is possible for me to alter all my database schemes and redo the replication, it seems to me that for a minor upgrade from 2.3.3 to 2.3.4, this is not the right way. May be it is more appropriate to set up some sort of configuration key that will allow to disable the check for those who really need now and announce that it will not work anymore from version 3.0?

this is the code that I had commented out

if has_primary_key?
raise ActiveRecord::ConfigurationError, "Primary key is not allowed in a has_and_belongs_to_many join table (#{@reflection.options[:join_table]})." end

Reported by Emin Hasanov · September 15th, 2009 @ 07:50 AM

State: new
Milestone: none
Assigned to: nobody
Importance: Low