adrian
I’m using distillery release hooks for running ecto migrations when the app starts. I’ve followed the distillery guide but is not working. The scrips are not being copied to the device.
This is the related config in the rel/config.exs file:
set commands: [
migrate: "rel/commands/migrate.sh",
seed: "rel/commands/seed.sh",
]
set pre_start_hooks: "rel/hooks/pre_start"
And under rel/hooks/pre_start I have the same migrate.sh file as in rel/commands/migrate.sh:
#!/bin/sh
# exit if any subcommand or pipeline returns a non-zero status.
set +e
echo "Starting migrations!"
release_ctl eval --mfa "Ui.ReleaseTasks.migrate/1" --argv -- "$@"
command
echo "Ending migrations!"
Thanks.
Adrián
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
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
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
So i have been using ash framework for a while and i love it. However currently the issue im having with ash framework is the error handl...
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 9- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
ConnorRigby
Nerves strips out any runtime components of Distillery. Check this post i wrote a while back to run Ecto migrations on Nerves devices.
mobileoverlord
Nerves does not support using distillery release hooks. This is because Nerves uses a program called erlinit to boot erlang as early and as safely as possible. Writing embedded systems using Nerves means that your application code will live mostly in Elixir / Erlang. This means that its really important that the VM comes up and stays running to prevent bricking the device. To make the boot process more reliable we created shoehorn, an OTP app that is included in Nerves projects by default.
Shoehorn provides two major advantages.
The second point is the one where you can perform actions similar to that of Distillery release hooks. Using Blinky as an example, we can see how the initial config.exs file is generated:
The option
:inittakes a list of OTP applications, and MFA’s to execute before the main application start. This is an ordered list. the default[:nerves_runtime, :nerves_init_gadget]means that:nerves_runtimeand its deps will start first, followed by:nerves_init_gadgetand its deps, followed by the main app declared in the key:app. You could add other OTP application names to this list or MFA’s such asinit: [{IO, :puts, ["init_1"]}]. Shoehorn has an example app that performs MFA’s on init hereadrian
Thanks a lot for your detailed answer @mobileoverlord!
What I’m trying to do is to run migrations for the Phoenix UI. I’ve added the migration release task to shoehorn but I get this error:
I guess this is because the Ui app has not started yet.
I start the apps before running the migrations, this is the script based on the distillery recommendations:
I think it fails because the Ui app has not started yet.
I’m not 100% sure about this, but I think the Ui is started with the app because it’s a dependency, but could I move the Ui start to soehorn instead of being done automatically? After that I could put the migrations script and remove the
start_servicesandstop_servicesfunctions.Does it make sense? Could it fail because starting up the db takes time and the migrations will run immediately?
@ConnorRigby the code I use is pretty similar to yours. Start the apps, migrate and stop.
I added to the Ui
application.exbut it doesn’t work either. The migrations work but after that, the Ui won’t start:
The repos were already started, I tried to stop them but somehow I still get this message.
ConnorRigby
So the reason that the
shoehornmethod won’t work seems to be because of a configuration error. I can’t say i’ve ever used this method so i’ll let Justin chime in on that.I still use ecto 2 so it’s possible something changed in the migration code, but in my application after running migrations, the repo is stopped. Which adapter are you using?
adrian
I used your code in the past and worked fine, I moved to PostgreSQL (the current adapter) and still worked fine. This was some months ago. After this I worked only in the UI, and in the way I upgraded versions. Everything worked for Phoenix, but last week when I tested the Ui in nerves, I got some issues. This is the one that is blocking the device to work.
ConnorRigby
are you using Ecto2 or Ecto3? as a quick hack you could essentially stop all Ecto/Repo processes before exiting the
Ui.ReleaseTasks.migrate()codeadrian
I already did that with:
And didn’t work.
I’m getting some results now.
I tried to start the ui and after that run the migrations adding at the end of shoehorn:
I removed the
start_servicesandstop_servicesbecause the ui was supposed to start it, but migrations didn’t run.Until I found out that I had a genserver for an AMQP service with RabbitMQ that had the wrong credentials, so it didn’t connect to RabbitMQ and the Ui was never fully started so migrations never run.
I just commented that genserver and migrations seems to run, but I’m just testing yet.
If I make this system work again in the RPI3, with custom buildroot with PostgreSQL, a nice Ui with Elm and websockets, realtime events using RabbitMQ, I’ll be very very excited
adrian
btw @ConnorRigby I forgot to mention I’m using Ecto3
adrian
It works!
After fixing the issue with the AMQP genserver adding this to shoehorn worked: