Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created schema not recognised #27

Open
Lazarus404 opened this issue Sep 22, 2014 · 5 comments
Open

Created schema not recognised #27

Lazarus404 opened this issue Sep 22, 2014 · 5 comments

Comments

@Lazarus404
Copy link

Hi,

So, I use the install task to create a schema, but when I try to access the database, I get

** (exit) {:aborted, {:no_exists, [UserStore.User, #PID<0.395.0>]}}
     stacktrace:
       mnesia.erl:310: :mnesia.abort/1
       lib/amnesia/table.ex:484: Amnesia.Table.read!/2
       (app) lib/app/connection_store.ex:6: App.UserStore.User.read!/1
       (app) lib/app/connection_store.ex:73: App.ConnectionStore.lookup/1
       test/app_test.exs:6

My Schema is created with:

deftable User, 
    [:pid,:username,:bytes,:datetime], 
    type: :set, 
    index: [:username] do
    @type t :: %User{pid: pid, 
                           username: String.t, 
                           bytes: non_neg_integer, 
                           datetime: {{non_neg_integer, non_neg_integer, non_neg_integer}, {non_neg_integer, non_neg_integer, non_neg_integer}}}

On install, the necessary folders do get created.

@meh
Copy link
Owner

meh commented Sep 22, 2014

Did you create the database after creating the schema? What's your creation code?

@Lazarus404
Copy link
Author

use Amnesia

defdatabase UserStore do
  @ver "0"

  deftable User, 
    [:pid,:username,:bytes,:datetime], 
    type: :set, 
    index: [:username] do
    @type t :: %User{pid: pid, 
                           username: String.t, 
                           bytes: non_neg_integer, 
                           datetime: {{non_neg_integer, non_neg_integer, non_neg_integer}, {non_neg_integer, non_neg_integer, non_neg_integer}}}
  end
end

defmodule Mix.Tasks.Install do
  use Mix.Task
  use UserStore

  def run(_) do
    Amnesia.Schema.create
    Amnesia.start
    XSignal.UserStore.create(disk: [node])
    XSignal.UserStore.wait
    Amnesia.stop
  end
end

@Lazarus404
Copy link
Author

I then run tun "mix install" followed by "iex -S mix" to get my app running

@Lazarus404 Lazarus404 changed the title Created schema no recognised Created schema not recognised Sep 22, 2014
@Lazarus404
Copy link
Author

Hi Meh,

Do you have a working example project that I can look over to see what the cause might be? Examples (other than in the readme.md" are few and far between.

Thanks

@meh
Copy link
Owner

meh commented Sep 22, 2014

Sadly no, all examples I have are private stuff I can't share.

Anyway, if what you have there is the code, please use create! instead of create, or check the return value because the database is probably raising errors on creation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants