Nebo15 / ecto_mnesia

Ecto adapter for Mnesia Erlang term database.
https://hex.pm/packages/ecto_mnesia
MIT License
242 stars 41 forks source link

Field :id does not exist #35

Closed mbenatti closed 7 years ago

mbenatti commented 7 years ago

Its suppose to create a ID automatically on migration right?

Error:

iex(7)> Tools.Model.Repo.all(Tools.Model.Embedded.Schemas.Feed)
** (ArgumentError) Field `:id` does not exist in table `:feed`
    (ecto_mnesia) lib/ecto_mnesia/record/context.ex:91: EctoMnesia.Record.Context.find_field_placeholder!/2
         (elixir) lib/enum.ex:1229: Enum."-map/2-lists^map/1-0-"/2
    (ecto_mnesia) lib/ecto_mnesia/record/context/match_spec.ex:17: EctoMnesia.Record.Context.MatchSpec.update/2
    (ecto_mnesia) lib/ecto_mnesia/planner.ex:57: EctoMnesia.Planner.execute/6
           (ecto) lib/ecto/repo/queryable.ex:130: Ecto.Repo.Queryable.execute/5
           (ecto) lib/ecto/repo/queryable.ex:35: Ecto.Repo.Queryable.all/4
iex(7)> 

My Schema:

defmodule Tools.Model.Embedded.Schemas.Feed do
  use Ecto.Schema

  schema "feed" do
    field :name, :string
    field :csv_origin_path, :string
    field :feed, :map
    field :is_valid, :boolean

    timestamps
  end
end

Migration file:

defmodule Tools.Model.Repo.Migrations.Feeds do
  use Ecto.Migration

  def change do
    create_if_not_exists table(:feeds, engine: :ordered_set) do
       add :name, :string
       add :csv_origin_path, :string
       add :feed, :map
       add :is_valid, :boolean

       timestamps()
    end
  end
end
AndrewDryga commented 7 years ago

Yes, id is created automatically unless you will set primary_key to false. Can you please, setup a test repo where this issues can be reproduced? I'll take look into it.

mbenatti commented 7 years ago

The error is: That the schema schema "feed" should be schema "feeds" like the migration.

Thank you Andrew!