This project is archived and is in readonly mode.

#3206 new
Emin Hasanov

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

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

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

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

People watching this ticket