We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Creating Idempotent Database Seeding in Elixir
438
clicks
Source: bitcrowd.dev
The article explains the importance of having idempotent seeds in Elixir applications to keep the development database predictable and clean after multiple seed runs. At Bitcrowd, they prefer using the upsert functionality to avoid creating additional rows in the database each time the seeding script is run. The seeds.exs file of a standard Phoenix app is enhanced with a helper function `insert_idempotently` to enable idempotent insertions. Furthermore, the article talks about generating deterministic UUIDs using a custom function in order to maintain idempotency for `has_many` associations. There's an alternative mention of using UUID Version-5 for deterministic UUID generation, but it highlights that creating a custom solution can be more engaging. The content points out the utility of having clean seeds in development and provides useful additional resources related to UUIDs.
Related posts
© HashMerge 2024