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

lighthouse-import opened this Issue May 16, 2011 · 3 comments


None yet
1 participant

Imported from Lighthouse. Original ticket at:
Created by Emin Hasanov - 2010-12-28 03:36:10 UTC

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

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]})."

Imported from Lighthouse.
Comment by pseudonym_ima - 2009-10-18 01:58:31 UTC

Imported from Lighthouse.
Comment by Rizwan Reza - 2010-02-12 12:46:18 UTC

[bulk edit]

Imported from Lighthouse.
Comment by Ryan Bigg - 2010-10-09 20:46:45 UTC

Automatic cleanup of spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment