Advertisement
Guest User

Untitled

a guest
Jun 16th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. To use hstore in Ecto schemas you have to create own Ecto type. To do this, follow these steps:
  2.  
  3. 1. Create files hstore.ex & hstore_extension.ex inside your lib folder
  4. 2. Open your database settings and add the following line
  5.  
  6. `extensions: [{MyApp.HStoreExtension, nil}],`, for example
  7.  
  8. ``` elixir
  9. config :my_app, MyApp.Repo,
  10. adapter: Ecto.Adapters.Postgres,
  11. username: "postgres",
  12. password: "",
  13. database: "database_name",
  14. extensions: [{MyApp.HStoreExtension, nil}],
  15. size: 100
  16. ```
  17.  
  18. - On postgrex 0.10 onwards, postgrex split the Binary extension across multiple files, so this fork uses the `Postgrex.Extensions.HStore` instead of the `Postgrex.Extensions.Binary`
  19. - Tested with Ecto 2.0.0-rc.6, Postgrex 0.11.2 and PostgreSQL 9.3.5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement