I’ve deployed my application to the production server today. Everything went good with a small exception - ActiveRecord generated slightly different SQL for relations in some modules.
Servers are 1:1 machines - same hardware, same software. I have same database structure and data on both servers too. But there’s this:
I have module that handles pages and their localizations. Both page and localization have a relation to User model, identified by user_id. On development, this works like a charm and generates
...FROM "users" "author" WHERE ("author"."[b]id[/b]"=:ypl0)
which is the right way and returns what it’s supposed to.
But when on production, it generates
...FROM "users" "author" WHERE ("author"."[b]username[/b]"=:ypl0)
instead and I’m unable to find a reason for this behavior. As I said, everything is copy 1:1.
The relation is defined by:
'author' => array( self::BELONGS_TO, 'User', 'user_id', 'together' => true )
in the right place. I even tried to add the ‘together’ option but there’s no change. Maybe the solution to this is pretty simple but I just don’t see it right now so I’m glad for any advice you might provide…
UPDATE: I might have found why it does that but still don’t know why it behaves like this only on production. ‘username’ is part of the primary key - same on both development and production but it behaves strange only on production.