fun_with_flags icon indicating copy to clipboard operation
fun_with_flags copied to clipboard

Allow Ecto.UUID PKs

Open vinniefranco opened this issue 3 years ago • 7 comments

Adds a compile-time config of :ecto_primary_key_type allowing use optional use of Ecto.UUID

vinniefranco avatar Mar 14 '22 20:03 vinniefranco

Thank you for opening the PR.

Can you explain why you think this is required? In other words, why do you need a UUID PK in the FWF table?

tompave avatar Mar 14 '22 22:03 tompave

Hi @tompave

Great question! So, the reason I need UUID-based PKs is due to the way our production environment is set up. Int based pk/fk are a no-go

vinniefranco avatar Mar 15 '22 00:03 vinniefranco

I see, that makes sense, but I'm not sure this is the right way to go about it. There is an open issue for how config is referenced in the ecto record file (https://github.com/tompave/fun_with_flags/issues/123), and this change would suffer from the same issue.

I'd be happy to accept a PR to fix the problem described in that issue, and then a second PR to add this new functionality using the correct compile-time config approach.

tompave avatar Mar 15 '22 12:03 tompave

I see, that makes sense, but I'm not sure this is the right way to go about it. There is an open issue for how config is referenced in the ecto record file (#123), and this change would suffer from the same issue.

I'd be happy to accept a PR to fix the problem described in that issue and then a second PR to add this new functionality using the correct compile-time config approach.

Yeah, I'm not sure that's the correct approach. put_meta is for already built structs, so while one could dynamically change the source right before an update/insert/delete, it appears one cannot dynamically change the primary key definitions at run-time especially when the primary key is configured using a compile-time module attribute.

It would be better to name and document what is explicitly compile-time and run-time, as I've run into issues configuring FWF between ct configs/<env.exs> and the rt release.exs with Mix.

I'm happy to help document the potential gotchas if need be

vinniefranco avatar Mar 15 '22 16:03 vinniefranco

Yeah, I'm not sure that's the correct approach.

Which one? The one in your PR, or what's discussed in that issue?

put_meta is for already built structs,

Yes, I don't think the suggestion in the opening message of that issue is the right one. I'm suggesting a different approach in my replies.

It would be better to name and document what is explicitly compile-time and run-time, as I've run into issues configuring FWF between ct configs/<env.exs> and the rt release.exs with Mix. I'm happy to help document the potential gotchas if need be

There were some gotchas, but they (or most of them) have been solved with the adoption of Application.compile_env. If you've run into issues configuring FWF in different envs I'd like to know if it was with an older version or with the latest. Chances are that you wouldn't have issues in the latest.

tompave avatar Mar 15 '22 21:03 tompave

Yes, I don't think the suggestion in the opening message of that issue is the right one. I'm suggesting a different approach in my replies.

Ahh, yes I see that. My apologies

vinniefranco avatar Mar 16 '22 16:03 vinniefranco

With regard to my message above (https://github.com/tompave/fun_with_flags/pull/129#issuecomment-1067934868), that has now been fixed with https://github.com/tompave/fun_with_flags/pull/130. If you still want to update this PR you can adopt that pattern.

tompave avatar Mar 20 '22 23:03 tompave

Closing because of inactivity.

tompave avatar Sep 11 '22 00:09 tompave