[英]Sidekiq PG::UndefinedColumn: ERROR: does not exist
I made a migration changing branch
to branch_name
for my phone_contact
model. 我为我的phone_contact
模型做了一个迁移,将branch
branch_name
为phone_contact
。 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. 如您所见, branch
不再列出。 It clearly states branch_name:
. 它明确指出branch_name:
So I pass in a record
, which is a hash with all of the above attributes to this worker. 因此,我传递了一个record
,它是具有上述所有属性的哈希值。 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 “ error_message” =>“ PG :: UndefinedColumn:错误:关系\\” phone_contacts \\“的列\\”分支\\“不存在\\ nLINE 1:插入\\” 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" ^ \\ n:INSERT INTO \\“ phone_contacts \\”(\\“ branch \\”,\\“ branch_id \\”,\\“ call_type \\”,\\“ client_id \\”,\\“ client_name \\”,\\“ created_at \\”,\\“ date_of_birth \\“,\\”电子邮件\\“,\\” 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 \\“,\\” visit \\“)值($ 1,$ 2,$ 3,$ 4,$ 5,$ 6,$ 7,$ 8, $ 9,$ 10,$ 11,$ 12,$ 13,$ 14,$ 15,$ 16,$ 17,$ 18,$ 19,$ 20)返回\\“ id \\”,“ error_class” =>“ ActiveRecord :: StatementInvalid”
The error changed to this with no code changes - I was just getting an unknown attribute: branch_name
error. 错误更改为此代码,没有更改代码-我只是得到了一个unknown attribute: branch_name
错误。
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. 我的迁移运行正常,当我在数据库中查看时,我看到branch_name,并且如果我使用Rails Console并手动逐个执行代码执行的步骤,则可以正常工作。 It only fails when I use Sidekiq
. 仅在使用Sidekiq
时失败。 I am using Ruby 2.0.0 and Rails 4.0.0. 我正在使用Ruby 2.0.0和Rails 4.0.0。
My opinion is that the schema is cached. 我的意见是该架构已缓存。 Have you tried restarting all of your workers? 您是否尝试过重新启动所有工作人员?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.