简体   繁体   English

Sidekiq PG :: UndefinedColumn:错误:不存在

[英]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_namephone_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.

相关问题 ActionView :: Template :: Error(PG :: UndefinedColumn:ERROR:列“weeknumber”不存在 - ActionView::Template::Error (PG::UndefinedColumn: ERROR: column “weeknumber” does not exist ActionView :: Template :: Error(PG :: UndefinedColumn:ERROR:列不存在) - ActionView::Template::Error (PG::UndefinedColumn: ERROR: column does not exist) PG::UndefinedColumn: 错误:列 services.zip_code 不存在 - PG::UndefinedColumn: ERROR: column services.zip_code does not exist 经典队列返回PG :: UndefinedColumn:错误:“ pid”列不存在 - queue classic returns PG::UndefinedColumn: ERROR: column “pid” does not exist PG :: UndefinedColumn:错误:列photos.attachable_type不存在 - PG::UndefinedColumn: ERROR: column photos.attachable_type does not exist PG :: UndefinedColumn:错误:列comment.post_id不存在 - PG::UndefinedColumn: ERROR: column comments.post_id does not exist PG :: UndefinedColumn:错误:关系“ courses”的列“ courseid”不存在 - PG::UndefinedColumn: ERROR: column “courseid” of relation “courses” does not exist PG :: UndefinedColumn:错误:列sections.row_order不存在 - PG::UndefinedColumn: ERROR: column sections.row_order does not exist PG::UndefinedColumn: 错误:courts.user_id 列不存在 - PG::UndefinedColumn: ERROR: column courts.user_id does not exist Pg文本搜索〜PG :: UndefinedColumn:错误:列document.content不存在 - Pg Text Search~ PG::UndefinedColumn: ERROR: column documents.content does not exist
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM