>>FIRST MISSION//LOGS//database//running-seeds-after-edeliver-deploy.MD
[ + ] TARGET_LOCKED200 OK
FEB 15, 2019timer 3 MIN READSYS_TAG: database STATUS: VERIFIED_WORKING

Running Seeds After Edeliver Deploy

ENGINE: KERNEL // STABLE
BASE_ARCH: x86_64
HOST: VASTORIGINS.COM
GPG: OKSIG_ID: 0x4EB27DB0

Success is neither magical nor mysterious. Success is the natural consequence of consistently applying basic fundamentals.

~ E. James Rohn.

After deploying your application to a production or staging server, have you ever wondered how you can import your seed data? The migrations run as part of the deploy, but the seed data, the initial admin user, the default categories, the reference rows every feature depends on, often has to be imported by hand. This post is specifically targeted to Elixir web apps only, and it shows the fastest way to run your seeds on a deployed release.

Assuming you haven’t already started the migration process and migrated all the tables, go to the built edeliver release folder and run ./bin/my_app_name remote_console to access the iex console for this web OTP (Open Telecom Platform) app. The remote console is your live window into the running release, and it is the same tool you would use for any emergency inspection.

When you’re inside the iex console, enter this command:

:code.priv_dir(:my_app_name)
|> Path.join("repo/seeds.exs") 
|> Code.require_file()

The command above will be evaluated by the console interpreter and run the seeds file. This would access the file from the priv directory and execute seeds.exs. The |> pipeline makes it read nicely: take the private directory, join it with the seeds path, and load the file into the running VM.

After that, check your database if all the migrations have been executed. A quick SELECT on one of the tables the seeds create is the fastest confirmation.

🧠 Final Thoughts

That’s all there is to it guys. The remote console is one of the most underrated tools in the Elixir world: instead of SSHing in and hoping the right commands exist on the server, you get a live REPL attached to your running app, with all its modules and configuration already loaded.

Whether you are seeding a fresh database or debugging a production issue, remote_console turns a scary operation into a normal day at the office. Check my other post for some additional tips and tricks. Hope you enjoyed this article!

[ SIGNATURE VERIFIED // GPG 0x4EB27DB0 // PROVENANCE SECURE ]
➔ RETURN TO LOGS