shahryarjb

shahryarjb

Mnesia has no access to create table in disc macOs dev mode

Hello, I have read many posts about disc problem in the forum, but I have still this problem:

I have no problem to create ram copy

 {:create_table,
  {:aborted, {:bad_type, MishkaAuth.User.Users, :disc_copies, :nonode@nohost}}}}

I did this comment before creating a post:

my config file:

config :mnesia, dir: "/Users/shahryar/Desktop/D-Access/mnesia_db"
# drwxr-xr-x   3 shahryar  staff         96 Mar 22 15:04 mnesia_db

My fields and mnesia name:

  @mnesia_tab __MODULE__

  @mnesia_tab_fields [
    :id,
    :full_name,
    :username,
    :email,
    :mobile,
    :password_hash,
    :unconfirmed_email,
    :unconfirmed_mobile,
    :roles,
    :scopes,
    :devices,
    :status,
    :inserted_at,
    :updated_at
  ]

And the function I create a disc_copies table

def start_mnesia() do
  :mnesia.stop()

  :mnesia.create_schema()
  |> IO.inspect(label: "Mnesia schema start of user ====>")

  :mnesia.start(:app)
  |> IO.inspect(label: "Application start of user ====>")


  case :mnesia.create_table(@mnesia_tab,
          type: :set,
          disc_copies: [Node.self()],
          attributes: @mnesia_tab_fields,
          index: [:username, :email, :mobile],
          record_name: @mnesia_tab,
          storage_properties: [ets: [{:read_concurrency, true}, {:write_concurrency, true}]]
        ) do
    {:atomic, :ok} -> :ok
    {:aborted, {:already_exists, @mnesia_tab}} -> :ok
    any -> {:error, {:create_table, any}}
  end
  |> IO.inspect(label: "Creating table ---->")

  :mnesia.wait_for_tables([@mnesia_tab], :timer.seconds(15))
  |> IO.inspect(label: "Mnesia wait for tables start of user ====>")
end

I am using mac os and dev mode with iex -S mix phx.server

Please help me to fix this issue, 3 or 4 years ago I fixed it, but I can not remember now :frowning:

Thank you in advance

Most Liked

rvirding

rvirding

Creator of Erlang

:wink: :smile: :wink: :smile:
Yes, Mnesia is an old Erlang tool and in Erlang strings are charlists. That’s the way it is.

shahryarjb

shahryarjb

I remove my custom path and it works, but I dont know why i can not set a dir for mnesia

for example if i set a path:

Application.put_env(:mnesia, :dir, "/Users/shahryar/Desktop/D-Access/mnesia_db")

or

:mnesia.stop()
Application.put_env(:mnesia, :dir, "/Users/shahryar/Desktop/D-Access/mnesia_db")

after that call

:mnesia..create_schema([node()])

It returns {:error, {:EXIT, :function_clause}}

I do not know why

Update

use this :rage: :rage: :rage: :rage: :rage: :rage:

Application.put_env(:mnesia, :dir, mnesia_dir |> to_charlist)

Where Next?

Popular in Questions Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
jc00ke
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217 Let’s say I have a map with required and optional k...
New

Other popular topics Top

TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

We're in Beta

About us Mission Statement