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

Improvements for Ecto #25

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

andrewtimberlake
Copy link

I was trying to migrate from bigint ids to TypeID
I came across a few problems because I need to have TypeID working during interim steps.

  1. You can’t use TypeID as a standard, non primary-key field (this would fail to pick up the prefix)
schema "table" do
  field :uuid, TypeID, prefix: "user", type: :binary_id
end
  1. You can’t set the foreign key type aside from using @foreign_key_type TypeID
belongs_to :model, Model, type: TypeID

This pull request addresses both usages
I didn’t see any Ecto tests, so I haven’t provided tests.

There is no need to return a different configuration for a primary key as it’s not used
@sloanelybutsurely
Copy link
Owner

hi! thanks for taking the time to contribute. i'll need a moment to review this more thoroughly but i did have some immediate feedback for you:

2. You can’t set the foreign key type aside from using @foreign_key_type TypeID

you can do this using define_field: false on the belongs_to and defining the foreign key field manually. See #20 (comment) for a more complete example.

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

Successfully merging this pull request may close these issues.

None yet

2 participants