Add postgres support for socket parameter (#136)

Simplifies connecting to postgres via sockets (https://github.com/amacneil/dbmate/issues/107), and standardize the `socket` parameter across both mysql and postgresql.

Closes #107
This commit is contained in:
Adrian Macneil 2020-05-24 17:12:41 -07:00 committed by GitHub
parent 45a122eb86
commit ed9e57a4ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 98 additions and 3 deletions

View file

@ -127,7 +127,7 @@ protocol://username:password@host:port/database_name?options
DATABASE_URL="mysql://username:password@127.0.0.1:3306/database_name"
```
A socket parameter can be specified to connect through a unix socket file:
A `socket` parameter can be specified to connect through a unix socket:
```sh
DATABASE_URL="mysql://username:password@/database_name?socket=/var/run/mysqld/mysqld.sock"
@ -141,6 +141,12 @@ When connecting to Postgres, you may need to add the `sslmode=disable` option to
DATABASE_URL="postgres://username:password@127.0.0.1:5432/database_name?sslmode=disable"
```
A `socket` or `host` parameter can be specified to connect through a unix socket (note: specify the directory only):
```sh
DATABASE_URL="postgres://username:password@/database_name?socket=/var/run/postgresql"
```
**SQLite**
SQLite databases are stored on the filesystem, so you do not need to specify a host. By default, files are relative to the current directory. For example, the following will create a database at `./db/database_name.sqlite3`: