Skip to content

Commit c8ba08c

Browse files
committed
Move IPv6 around and to ecto_sql repo
1 parent 4978825 commit c8ba08c

2 files changed

Lines changed: 16 additions & 62 deletions

File tree

README.md

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,6 @@ See the [getting started guide](https://hexdocs.pm/ecto/getting-started.html) an
8181

8282
* [The Little Ecto Cookbook](https://dashbit.co/ebooks/the-little-ecto-cookbook), a free ebook by Dashbit, which is a curation of the existing Ecto guides with some extra contents
8383

84-
### IPv6 support
85-
86-
Does not happen automagically. If your database's host resolves to ipv6 address you should
87-
add `socket_options: [:inet6]` to configuration block like below:
88-
89-
```elixir
90-
import Mix.Config
91-
92-
config :your_app, :tds_conn,
93-
hostname: "db12.dc0.comp.any",
94-
username: "test_user",
95-
password: "test_password",
96-
database: "lomaster",
97-
port: 1433,
98-
socket_options: [:inet6] # here you may also add all the options for `gen_tcp` erlang module
99-
```
100-
10184
## Usage
10285

10386
You need to add both Ecto and the database adapter as a dependency to your `mix.exs` file. The supported databases and their adapters are:
@@ -142,6 +125,20 @@ defmodule MyApp.Repo do
142125
...
143126
```
144127

128+
### IPv6 support
129+
130+
If your database's host resolves to ipv6 address you should
131+
add `socket_options: [:inet6]` to configuration block like below:
132+
133+
```elixir
134+
import Mix.Config
135+
136+
config :my_app, MyApp.Repo,
137+
hostname: "db12.dc0.comp.any",
138+
socket_options: [:inet6],
139+
...
140+
```
141+
145142
## Supported Versions
146143

147144
| Branch | Support |

guides/introduction/Getting Started.md

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -119,49 +119,6 @@ This tells our application about the repo, which will allow us to run commands s
119119

120120
We've now configured our application so that it's able to make queries to our database. Let's now create our database, add a table to it, and then perform some queries.
121121

122-
### IPv6 support
123-
124-
Does not happen automagically. If your database's host resolves to ipv6 address you should
125-
add `socket_options: [:inet6]` to configuration block like below:
126-
127-
```elixir
128-
import Mix.Config
129-
130-
config :your_app, :your_connection,
131-
hostname: "db12.dc0.comp.any", # just an example
132-
socket_options: [:inet6] # here you may also add all the options for `gen_tcp` erlang module
133-
# ... other options
134-
```
135-
136-
### Unix socket connection
137-
138-
For faster communication, you may consider communicating with Postgres via Unix sockets.
139-
If your PG server was started on the same machine as your code, you could check that.
140-
141-
```bash
142-
% sudo grep unix_socket_directories /var/lib/postgres/data/postgresql.conf
143-
unix_socket_directories = '/run/postgresql'
144-
```
145-
146-
```bash
147-
% ls -lah /run/postgresql
148-
итого 4,0K
149-
drwxr-xr-x 2 postgres postgres 80 июн 4 10:58 .
150-
drwxr-xr-x 35 root root 840 июн 4 21:02 ..
151-
srwxrwxrwx 1 postgres postgres 0 июн 5 07:41 .s.PGSQL.5432
152-
-rw------- 1 postgres postgres 61 июн 5 07:41 .s.PGSQL.5432.lock
153-
```
154-
155-
So you have postgresql started and listening on the socket.
156-
157-
Add then this line to config block:
158-
159-
```elixir
160-
config :your_app, :your_connection,
161-
# ...
162-
socket_dir: "/run/postgresql"
163-
```
164-
165122
## Setting up the database
166123

167124
To be able to query a database, it first needs to exist. We can create the database with this command:
@@ -751,9 +708,9 @@ changeset = Friends.Person.changeset(person, %{first_name: ""})
751708
Friends.Repo.update(changeset)
752709
#=> {:error,
753710
#Ecto.Changeset<
754-
action: :update,
711+
action: :update,
755712
changes: %{},
756-
errors: [first_name: {"can't be blank", [validation: :required]}],
713+
errors: [first_name: {"can't be blank", [validation: :required]}],
757714
data: #Friends.Person<>,
758715
valid?: false
759716
>}

0 commit comments

Comments
 (0)