sezaru
Is there any global configuration I change use to change both the default Ash.UUID.generate/0 function and gen_random_uuid() functions for uuid fields?
For example, I want to use uuid_v7 by default.
I know I can at least change the default Ash.UUID.generate/0 by using the default option in each attribute, but I believe in some cases that is not sufficient (ex. with an ash_authentication user_resource)
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
zachdaniel
IIRC
ash_authenticationwill only add the id attribute if you haven’t already. I don’t believe there is a way to do it globally at the moment.sezaru
Ah, that’s true. I added a separated field for the id and it worked just fine.
That actually brings me to another question.
Is it possible to configure an
Ash.Typeto use some specific fragment for when generating migrations?For example, I have my own
Ash.TypeforUUIDV7. I want to make it that when i add this attribute to some resource, it will automatically set thedefaultpostgres value asuuid_generate_v7()the same way that adding the default uuid primary key field for Ash adds thegen_random_uuid().Of course, I can add that using the
migration_defaultsfunction, but that means that I need to do that for basically every resource in my system (since they all use myUUIDV7type), it would be great if I could make that be added automatically.I saw that there is a
AshPostgres.Typethat adds a callback for a function calledvalue_to_postgres_default, but that function doesn’t seem to be used to generate that default.Maybe we could add a new callback for
AshPostgres.Typecalled@callback migration_default/0where the user defines what is the default migration default value for the type that implements it?zachdaniel
Ah, so TBH I don’t think you actually want all usages of that type get a default value. Otherwise
belongs_to :something, SomethingElse, type: UUIDV7would also get a default value, which would fail to insert if that relationship is optional.What I’d suggest is adding this to your app:
Then you can
use MyApp.Resourceinstead ofuse Ash.Resource, and haveuuid_v7_primary_keyavailable.With all of that said, the next release of Ash will have uuidv7 built in to core, so maybe you just want to use that?
sezaru
Yep, that is actually what I used. Here is my implementation:
What bothered me with that is that this would not add
defaultasuuid_generate_v7()in the postgres layer, it will benilbut theuuid_primary_keywill addgen_random_uuid()as the default in postgres layer.Is that built-in uuidv7 implementation already in master? Can it be tested already? that would be super great!
zachdaniel
Yes, it is available in
ash,main, but theash_postgreschanges are waiting to be merged untilashhas been released, unfortunately. But you could try the branch from the PR.improvement: add support for `:uuid_v7` type by moissela · Pull Request #333 · ash-project/ash_postgres · GitHub