I made a migration changing branch
to branch_name
for my phone_contact
model. I then changed my code to this:
class ContactWorker
include Sidekiq::Worker
def perform(record, service_type = 'test', list_type = 'test')
phone_contact = PhoneContact.create(
client_id: record['ClientID'],
client_name: record['ClientName'],
branch_id: record['branchID'],
branch_name: record['branch'],
unit_id: record['UnitID'],
member_id: record['MemberID'],
first_name: record['FirstName'],
last_name: record['LastName'],
date_of_birth: record['DateofBirth'],
most_recent_join_date: record['ChangeDate'],
old_membership_type: record['OldMembershipType'],
membership_type: record['NewMembershipType'],
phone_number: record['HomePhone'],
email: record['EMailAddress'],
visits: record['ID__Visits'],
primary_language: record['PrimaryLanguage'],
call_type: record['CallType'],
list_id: "#{Time.new.strftime("%Y_%m_%d")}_#{service_type}_#{list_type}"
)
end
end
As you can see, branch
is no longer listed. It clearly states branch_name:
.
So I pass in a record
, which is a hash with all of the above attributes to this worker. Regardless of what that hash looks like, this is the error I receive:
"error_message"=>"PG::UndefinedColumn: ERROR: column \"branch\" of relation \"phone_contacts\" does not exist\nLINE 1: INSERT INTO \"phone_contacts\" (\"branch\", \"branch_id\", \"call_t...\n
^\n: INSERT INTO \"phone_contacts\" (\"branch\", \"branch_id\", \"call_type\", \"client_id\", \"client_name\", \"created_at\", \"date_of_birth\", \"email\", \"first_name\", \"last_name\", \"list_id\", \"member_id\", \"membership_type\", \"most_recent_join_date\", \"old_membership_type\", \"phone_number\", \"primary_language\", \"unit_id\", \"updated_at\", \"visits\") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20) RETURNING \"id\"", "error_class"=>"ActiveRecord::StatementInvalid"
The error changed to this with no code changes - I was just getting an unknown attribute: branch_name
error.
What could be causing this? My migration ran fine, when I look in my database i see branch_name, and if I use the Rails Console and manually go through the steps that my code is going through, one by one, it works fine. It only fails when I use Sidekiq
. I am using Ruby 2.0.0 and Rails 4.0.0.
My opinion is that the schema is cached. Have you tried restarting all of your workers?