Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make foreign key association? #472

Open
kunalvashistordway opened this issue Oct 29, 2020 · 2 comments
Open

How to make foreign key association? #472

kunalvashistordway opened this issue Oct 29, 2020 · 2 comments

Comments

@kunalvashistordway
Copy link

class Workflow
  include Dynamoid::Document
  include SecureRandom

  table name: :workflows, key: :company_id

  range :api_name

  has_many :workflow_logs

  field :company_id, :integer
  field :api_name
  field :workflow_id, :string, default: SecureRandom.uuid
}
class WorkflowLog
  include Dynamoid::Document
  table name: :workflow_logs
  belongs_to :workflow, foreign_key: :workflow_id
  field :company_id, :integer
end

Workflow has primary partition key as company id and sort key api name, i want workflow_id to be foreign key for workflow logs, but its taking company_id value for workflow logs

@andrykonchin
Copy link
Member

Could you please provide example of code to reproduce the issue?

@andrykonchin
Copy link
Member

andrykonchin commented Oct 31, 2020

The only thing I remember is that associations don't work now when primary key is compound - when there is a range/sort key. So WorkflowLog cannot belong to a model with range/sort key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants