smpallen99
Just released a new package on hex for tracking changes to your Ecto models.
Its functional, but in the early stages. Could use some additional features like restore, version limits, etc. Let me know what you think.
Trending in Announcing
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub.
Docs are at OpenaiEx User Gu...
New
WebAuthnLiveComponent WebAuthnComponents
See this post about renaming the package.
Passwordless authentication for Phoenix LiveView app...
New
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
I released Doggo, a collection of unstyled Phoenix components.
https://github.com/woylie/doggo
Features
Unstyled Phoenix components....
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Castle is a package I put together to assist with building Elixir releases capable of being live-upgraded via the ‘official’ release hand...
New
Other Trending Topics
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
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with.
But I don’t use it anymore.
Serverless was the promis...
New
What IDE or editor are you using for Elixir development?
Personally, I use Zed, and I really like it, but sometimes I wish there were a ...
New
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
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
- #ai
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #metaprogramming











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
OvermindDL1
Huh, was actually thinking of making something like this myself. A question though, I notice that it seems to require a User schema of some form to mark
whodoneit, however in my system the User is in an LDAP system (not exposed via Ecto since Ecto2 has no LDAP interface, as well as it would not work cross-repo anyway), and the unique ID from the LDAP database is abigintinteger in Ecto. How would I give it the bigint unique ID that does not have a corresponding ecto schema?smpallen99
It does not need a user model if you don’t want to track who made the change. Please add an issue if want to see support for an LDAP based user model.
To suport your use case, I think we can add an option to the installer for this. Something that would set the user_id to a simple field with a provided type. For the user name, we could add support for a {module, fun} tuple and call the fun if its a tuple.
What do you think?
Steve
OvermindDL1
That would be nice! All I’d need to store for ‘who’ made the change is a PostgreSQL bigint integer or larger, and that is included in the assign on every request or nil if not logged in, though it would be nice to, say, save the IP of the person making the change too perhaps? How about a user defined User, either a table reference or a base type like
:bigint, as well as a metadata section (:mapperhaps?) so we could store other things like IP address?smpallen99
I have about half of it implemented now with the syntax
whatwasit.install —whodoneit-id=bigintsyntax. Then you set name_field: {Mod, Fun} to fun/1 that will be called with the whodoneit-id to fetch the name.Storing a map would be an interesting idea too. As I work though this, I’m thinking generating the Version model from a template in the projects namespace. This would all full customization of the fields.
OvermindDL1
Just as a comparison, my original idea for a module like this was less generic, I was planning an interface to use PostgreSQL’s natural ability to mark rows as ‘deleted/invalid’ and they no longer appear after in SQL queries (unless you use a specific one to get those specifically deleted ones), thus you can version that way. Could store something like a user on the table itself for example. I am unsure which method is better actually…
brightball
I had no idea PostgreSQL could do that…do you have an example handy?
OvermindDL1
There are a few ways. PostgreSQL used to have actual Time Travel functionality built in a long time ago but was removed for ANSI compliance over time and is now emulatable via: PostgreSQL: Documentation: 9.5: spi
Honestly that is overkill though, and database specific (which much of my code is anyway), and I am using such a row history as it is on one of my tables. On one of my tables I need to keep all history, and yet it is dynamic. I could have made a logging table but that is extra work so all I did was add a column of (in addition to the other primary keys):
On initial write I set it far in the future (specific date of 294275 AD), on every query I add the
294275 ADdate to the query via a helper on the schema. On write I update the:invalidated_atof the old row tonow()and write out the new row with the new data with the294275 ADfuture date. On delete I just set the:invalidated_attonow(). This is not a generic style that would be useful in most situations, not a good style for storing, say, who did it, although with minor modifications to some of the ordering it would be.That table grew over a few versions to do that, I was thinking of redesigning it (would not need to be a primary key with an idea I have) with a set of helpers that I could pull out into a library to manage it for me, something as simple as just dropping another
timestamps-like call into the migration and schema with a set of options it could take along. It would have been postgresql specific due to using its built in time handling functions though.smpallen99
I just published 0.2.0 on hex. This version has a mix whatwasit.install —whodoneit-map option that will save your user struct in the database as a map. This should work with any struct and not just an Ecto schema.
Steve
OvermindDL1
Awesome, much more generically useful!
Eiji
Is it support:
I want to retrieve a user all activity history (create, delete, update - on update what was changed + diff if changed value is a string), so admin can control users work.