Eiji

Eiji

Hey, I have really weird problem. I’m working on something which have task to create mnesia database and would require to call use few times. At compilation time (in __using__/1 macro) I’m saving some things into database. If database is not yet created I’m skipping database-specific work and simply use IO.warn/1.

The problem is that when (after previous compilation) I’m creating database and then I’m running mix compile --force then it looks like that macro is called, but there are no entries in database.

When I update macro by simply adding some IO.inspect or IO.puts (for debugging purposes) then after compilation it suddenly works, so it looks like that some piece of code is cached and not running on compile time even if I force project compilation. Of course calling task before final project compilation solves the problem, but again I can’t drop mnesia database and force recompile project.

Is there an option to fully recompile project or at least only every module which uses specific module?

Showing Posts 1 to 4

hauleth

hauleth

Dear gods, it is absolutely terrible. Before going anywhere from there, let me just ask: WHY?

Eiji

Eiji OP

No matter if mnesia or other solution I need to save some data on compile time. It could look weird, but it’s my private project assumption. I don’t want to describe everything now. In short I want to store some data and later use them dynamically.

For simplicity imagine that every time you call use Ecto.Repo module (as __MODULE__ in __using__/1 is saved as key in repositories table, so it could be later used to dynamically fetch all project repositories without setting them in config :my_app, :ecto_repos, […] manually. Of course my case is much more bigger than single key mnesia table - it’s just to show an example of storing some things on compile time which could be fetched dynamically.

To be honest it’s also not even a big priority for me. I just found that mistake like removing mnesia directory manually or by mix task causes problem, because I can’t recompile and re-fill database.

dimitarvp

dimitarvp

Have you tried replacing your compile-time inserting in a database with a mix task? That could help you with testing it as well.

Eiji

Eiji OP

@dimitarvp: Oh, I’m really sorry for delay. I was a bit busy last time. :slight_smile:

Even before you wrote this I have already found a solution. I made a stupid mistake with check if database is working. After updating code compilation does not skip important code which saves my information to mnesia database.

Answering your question. In my specific case I can’t moved code to mix task. In mix task I have only creating database. Inserting data to tables happens at compile time. Of course I could do it with some example data, but even doing that I would not copy copy which checks if database is working (because in this task I’m already creating it and ensuring its started), so I would not even reproduce problem. :smiley:

Anyway thank you all for help. I though that some code is seriously not called again using force argument. Fortunately I was wrong. :077:

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
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
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
ryanwinchester
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted” Version...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews