GigCity Elixir wrapped, new AshEvents extension, "Domain Modeling with Ash Framework" book launch, c

Ash Weekly: Issue #16
GigCity Elixir wrapped, new AshEvents extension, "Domain Modeling with Ash Framework" book launch, combination query feature released.
26 Replies
sevenseacat
sevenseacat5mo ago
I was about to go 'aaaaaaah' based on one line in the newsletter email but I see it's already been fixed in the online version 👍
ZachDaniel
ZachDanielOP5mo ago
Yeah someone messaged me that I had tripled my negative 😂
sevenseacat
sevenseacat5mo ago
lol uh huh
Ahrou
Ahrou5mo ago
our team was just looking to implement auditing in our app what nice timing 🙌 we tried ash_paper_trail but it does not include the actor in the same was as this what is the right way to handle the migrations? our app atm has no automatic migrations, we are managing the SQL directly with an external team. Is it ok to just create the table manually from this? https://github.com/ash-project/ash_events/blob/main/priv/test_repo/migrations/20250417180632_migrate_resources1.exs#L76 (changing the record_id type to text because legacy ids are not uuid 🫠) also is there any way to define which attribute we want to set in the actor? i see it grabs the primary key but in our case it doesnt work in some actors we have these types of actors:
attribute :type, :atom,
constraints: [one_of: [:operator, :developer, :support, :inspector, :guest, :user]]
attribute :type, :atom,
constraints: [one_of: [:operator, :developer, :support, :inspector, :guest, :user]]
and im seeing in the docs that maybe we did not define our actors properly and it should be two different resources then 🤔. the :user type is the one that has an user_uuid pk, the other types of actors are support users so we did not bother with ids, we have emails idk if this is the right place to have these discussions mb if not 🙏
barnabasj
barnabasj5mo ago
Newsletter only designed for dark mode 😅
sevenseacat
sevenseacat5mo ago
all the cool kids use dark mode
ZachDaniel
ZachDanielOP5mo ago
Oh does it look wrong 😅 whoops @Ahrou id suggest opening issues on the project It's a new thing and only just got its 0.1 release so may be a bunch of things to work out based on how others want to use it
Ahrou
Ahrou5mo ago
will create issues then thanks 🙏
barnabasj
barnabasj5mo ago
it's white lettering on a white background
barnabasj
barnabasj5mo ago
No description
ZachDaniel
ZachDanielOP5mo ago
🥹 @Ahrou just FYI: if all you want is an audit trail, you should IMO use ash_paper_trail you can persist the actor but ash_events comes with tradeoffs/limitations you have to agree to to use it.
Ahrou
Ahrou5mo ago
i read the differences here https://github.com/ash-project/ash_events?tab=readme-ov-file#differences-from-ash_paper_trail-with-regards-to-audit-logging and we were more inclined in using AshEvents, we want a single table and only the changes saved. I dont think we would need options for change tracking and storing action inputs
GitHub
GitHub - ash-project/ash_events: An event-architecture extension fo...
An event-architecture extension for Ash. Contribute to ash-project/ash_events development by creating an account on GitHub.
ZachDaniel
ZachDanielOP5mo ago
Right, but you also need to consider the constraints
ZachDaniel
ZachDanielOP5mo ago
GitHub
GitHub - ash-project/ash_events: An event-architecture extension fo...
An event-architecture extension for Ash. Contribute to ash-project/ash_events development by creating an account on GitHub.
ZachDaniel
ZachDanielOP5mo ago
But yeah, if you want one event log etc then perhaps that is your best bet 🤷‍♂️
Ahrou
Ahrou5mo ago
i see, hadnt looked at that section since we are not planning to have complete events, we followed the section Using AshEvents for Audit Logging Only so in the audit logs only case that wouldnt be an issue?
ZachDaniel
ZachDanielOP5mo ago
Um...yeah possibly actually you're probably right if you don't want replay, you don't have to follow all the caveats.
Chaz Watkins
Chaz Watkins5mo ago
It looks like paper_trail provides the opts necessary to have a single Version resource that stores entries from multiple resources. If this is incorrect, feel free to correct me.
ZachDaniel
ZachDanielOP5mo ago
I believe you could, yes
Ahrou
Ahrou5mo ago
i tried paper_trail last week, and correct me if im wrong, but i think there is no resource column, so we would not be able to distinguish them easily
ZachDaniel
ZachDanielOP5mo ago
You could use the version mixin to give them all the same table
Ahrou
Ahrou5mo ago
from what i could see while testing it, this is the table for _versions right?
id uuid,
changes JSONB NOT NULL,
version_source_id UUID NOT NULL,
version_action_name text,
version_action_type VARCHAR(50) NOT NULL,
version_inserted_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
version_updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
id uuid,
changes JSONB NOT NULL,
version_source_id UUID NOT NULL,
version_action_name text,
version_action_type VARCHAR(50) NOT NULL,
version_inserted_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
version_updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
if we store every Resource in this table, there is no resource column to filter them, like in AshEvents right?
ZachDaniel
ZachDanielOP5mo ago
Correct, but we could add an option store something like that. Not pushing you to use it though An interesting overlap at the end of the day
Ahrou
Ahrou5mo ago
then we could use ash_paper_trail, there was just another issue, the version_source_id type is different in many resources from uuid to integer, to varchar 🫠 maybe i will discuss with the team if we want to have a single table for each resource 🤔
Chaz Watkins
Chaz Watkins5mo ago
There's a couple options for storing the resource identifer too
No description
Chaz Watkins
Chaz Watkins5mo ago
Try setting store_resource_identifier?: true to see if it adds a column to the table and stores the resource's short_name. Also, we should probably move this conversation to https://discord.com/channels/711271361523351632/1253438465543245844

Did you find this page helpful?