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
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication):
toke...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
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 everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #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
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










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