{"action":"created","issue":{"url":"https://api.github.com/repos/Nebo15/ecto_mnesia/issues/18","repository_url":"https://api.github.com/repos/Nebo15/ecto_mnesia","labels_url":"https://api.github.com/repos/Nebo15/ecto_mnesia/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/Nebo15/ecto_mnesia/issues/18/comments","events_url":"https://api.github.com/repos/Nebo15/ecto_mnesia/issues/18/events","html_url":"https://github.com/Nebo15/ecto_mnesia/issues/18","id":196283312,"number":18,"title":"Custom primary keys, it works?","user":{"login":"JanStevens","id":1540483,"avatar_url":"https://avatars.githubusercontent.com/u/1540483?v=3","gravatar_id":"","url":"https://api.github.com/users/JanStevens","html_url":"https://github.com/JanStevens","followers_url":"https://api.github.com/users/JanStevens/followers","following_url":"https://api.github.com/users/JanStevens/following{/other_user}","gists_url":"https://api.github.com/users/JanStevens/gists{/gist_id}","starred_url":"https://api.github.com/users/JanStevens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JanStevens/subscriptions","organizations_url":"https://api.github.com/users/JanStevens/orgs","repos_url":"https://api.github.com/users/JanStevens/repos","events_url":"https://api.github.com/users/JanStevens/events{/privacy}","received_events_url":"https://api.github.com/users/JanStevens/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-12-18T16:03:43Z","updated_at":"2016-12-18T16:38:33Z","closed_at":null,"body":"Hello,\r\n\r\nI see the readme stating that custom primary keys is still a work in progress but I managed to get it to work, my fear is that this is wrong and its not yet fully supported. Whats the current state of it?\r\n\r\nSchema\r\n```elixir\r\n  @primary_key {:uuid, :string, []}\r\n  @derive {Phoenix.Param, key: :uuid}\r\n\r\n  schema \"device_configs\" do\r\n    field :environment, :string, default: \"staging\"\r\n    field :configs, :map, default: %{}\r\n    timestamps()\r\n  end\r\n```\r\n\r\nMigration\r\n```elixir\r\n    create_if_not_exists table(:device_configs, primary_key: false) do\r\n      add :uuid, :string, primary_key: true\r\n      add :environment, :string, default: \"staging\"\r\n      add :configs, :map, default: %{}\r\n\r\n      timestamps()\r\n    end\r\n```\r\n\r\n```\r\nDevicesEx.Repo.insert(%DevicesEx.DeviceConfig{uuid: \"ACR001\"})\r\n{:ok,\r\n %DevicesEx.DeviceConfig{__meta__: #Ecto.Schema.Metadata<:loaded, \"device_configs\">,\r\n  configs: %{}, environment: \"staging\",\r\n  inserted_at: ~N[2016-12-18 15:50:21.840696],\r\n  updated_at: ~N[2016-12-18 15:50:21.847592], uuid: \"ACR001\"}}\r\niex(5)> DevicesEx.Repo.all(query)\r\n[debug] Selecting by match specification `[{{:device_configs, :\"$1\", :\"$2\", :\"$3\", :\"$4\", :\"$5\"}, [], [[:\"$1\", :\"$2\", :\"$3\", :\"$4\", :\"$5\"]]}]` with limit `nil`\r\n[%DevicesEx.DeviceConfig{__meta__: #Ecto.Schema.Metadata<:built, \"device_configs\">,\r\n  configs: %{}, environment: \"staging\",\r\n  inserted_at: {{2016, 12, 18}, {15, 50, 21, 840696}},\r\n  updated_at: {{2016, 12, 18}, {15, 50, 21, 847592}}, uuid: \"ACR001\"}]\r\niex(6)> DevicesEx.Repo.insert(%DevicesEx.DeviceConfig{uuid: \"ACR001\"})\r\n** (CaseClauseError) no case clause matching: {:error, :already_exists}\r\n    (ecto) lib/ecto/repo/schema.ex:459: Ecto.Repo.Schema.apply/4\r\n    (ecto) lib/ecto/repo/schema.ex:198: anonymous fn/11 in Ecto.Repo.Schema.do_insert/4\r\n```"},"comment":{"url":"https://api.github.com/repos/Nebo15/ecto_mnesia/issues/comments/267831292","html_url":"https://github.com/Nebo15/ecto_mnesia/issues/18#issuecomment-267831292","issue_url":"https://api.github.com/repos/Nebo15/ecto_mnesia/issues/18","id":267831292,"user":{"login":"AndrewDryga","id":1877644,"avatar_url":"https://avatars.githubusercontent.com/u/1877644?v=3","gravatar_id":"","url":"https://api.github.com/users/AndrewDryga","html_url":"https://github.com/AndrewDryga","followers_url":"https://api.github.com/users/AndrewDryga/followers","following_url":"https://api.github.com/users/AndrewDryga/following{/other_user}","gists_url":"https://api.github.com/users/AndrewDryga/gists{/gist_id}","starred_url":"https://api.github.com/users/AndrewDryga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndrewDryga/subscriptions","organizations_url":"https://api.github.com/users/AndrewDryga/orgs","repos_url":"https://api.github.com/users/AndrewDryga/repos","events_url":"https://api.github.com/users/AndrewDryga/events{/privacy}","received_events_url":"https://api.github.com/users/AndrewDryga/received_events","type":"User","site_admin":false},"created_at":"2016-12-18T16:38:33Z","updated_at":"2016-12-18T16:38:33Z","body":"Actually, I can't even guess :). Looks like it should work, but I have never tried this way. And in nearest future I will work on Ecto integrations tests to merge this PR https://github.com/elixir-ecto/ecto/pull/1865, so can't tell when I will be able to get back to PK's."}}
{"actor":{"display_login":"AndrewDryga"}}