Commit graph

164 commits

Author SHA1 Message Date
Adrian Macneil
61771e386d
Refactor drivers into separate packages (#179)
`dbmate` package was starting to get a bit polluted. This PR migrates each driver into a separate package, with clean separation between each.

In addition:

* Drivers are now initialized with a URL, avoiding the need to pass `*url.URL` to every method
* Sqlite supports a cleaner syntax for relative paths
* Driver tests now load their test URL from environment variables

Public API of `dbmate` package has not changed (no changes to `main` package).
2020-11-19 15:04:42 +13:00
Adrian Macneil
c907c3f5c6
Ability to specify custom migrations table name (#178)
Supported via `--migrations-table` CLI flag or `DBMATE_MIGRATIONS_TABLE` environment variable.

Specified table name is quoted when necessary.

For PostgreSQL specifically, it's also possible to specify a custom schema (for example: `--migrations-table=foo.migrations`).

Closes #168
2020-11-17 18:11:24 +13:00
Adrian Macneil
656dc0253a
Update docs (#175) 2020-11-10 14:09:53 +13:00
Adrian Macneil
c2b14bb7e0
v1.11.0 (#174) 2020-11-10 12:38:51 +13:00
Adrian Macneil
e44e09eb67
Migrate CI to GitHub Actions (#171) 2020-11-02 20:22:59 +13:00
Enrico
2950db7131
mysql: Create the schema_migrations table using latin1 charset (#172)
Force the `schema_migrations` table to be created with `latin1` character set, to fix the behavior of dbmate in MariaDB 10.1 and older (or MySQL 5.6 and older) when the system charset has more than 1 byte per character (e.g. utf8mb4)

Closes #85
2020-11-02 12:02:28 +13:00
Adrian Macneil
5b7e6cef18
Add codeql-analysis.yml (#163) 2020-11-01 18:30:30 +13:00
Adrian Macneil
203065661c
Properly check errors from sql.Rows (#170) 2020-11-01 15:30:20 +13:00
Adrian Macneil
ac718a23dc
postgres: Automatically create search_path schema when needed (#169)
In #167 we added support for specifying a postgres `search_path`, which is used to store the `schema_migrations` table. However, if the schema does not already exist it will cause an error.

In this PR we automatically create the first schema in the `search_path` if it does not exist.
2020-11-01 15:09:13 +13:00
Adrian Macneil
55a8065efe
postgres: Support custom schema for schema_migrations table (#167)
Instead of hardcoding `schema_migrations` table to the `public` schema, add support for specifying a schema via the `search_path` URL parameter.

**Backwards compatibility note**: If anyone was using the previously undocumented `search_path` behavior (affecting migrations themselves, but always storing the `schema_migrations` table in `public`), you will need to either prepend `public` to your `search_path`, or migrate your `schema_migrations` table to your primary schema:

```sql
ALTER TABLE public.schema_migrations SET SCHEMA myschema;
```

Closes #110
2020-11-01 13:30:35 +13:00
Adrian Macneil
d4ecd0b259
postgres: Limit pg_dump to schemas in search_path (#166) 2020-10-31 17:13:49 +13:00
Adrian Macneil
af41fbfb4e
Make golint happy (#165) 2020-10-30 19:04:02 +13:00
Adrian Macneil
2b3f59fbe3
Go v1.15 (#161) 2020-09-27 14:50:30 -07:00
Adrian Macneil
26f17d5141
Document migration order (#160) 2020-09-24 10:14:31 -07:00
Adrian Macneil
616c4fe442
v1.10.0 (#158) 2020-08-13 08:30:58 -07:00
Adrian Macneil
4387633e1f
Add sql clients to docker image (#157)
Instead of a nice super-minimal production docker image, create one based on alpine with sql clients installed (`mariadb-client`, `postgresql-client`, and `sqlite`).

* Increases docker image size from 10 MB to 56 MB 👎 
* Allows people to run `dbmate dump` command with our docker image (fixes #114) 👍 
* I'm not sure what compatibility is like between `mysqldump` from `mariadb-client` versus `mysql-client`, but starting here since mariadb is included with alpine, and the version I built using mysql and ubuntu weighed in at 165 MB. 🤔
2020-08-11 15:36:07 -07:00
Adrian Macneil
4581acafad
Build statically linked binaries (#156)
Prior to this commit, we released two linux binaries:

* `dbmate-linux-amd64` (built with cgo, dynamically linked)
* `dbmate-linux-musl-amd64` (built without cgo, statically linked, no sqlite support)

The statically linked binary is desirable for alpine linux users (or anyone else using musl libc or minimal docker images). The original reason for having two separate binaries was that the easiest method to create a static binary for go is to set `CGO_ENABLED=0`, but unfortunately this also prevented us from building sqlite (which requires cgo).

With this commit, all linux and windows binaries are explicitly statically linked while leaving cgo enabled. Hat tip to https://www.arp242.net/static-go.html which explained the necessary flags to enable this.

As an added bonus, the `dbmate` docker image now now uses a `scratch` base rather than `gcr.io/distroless/base`, reducing the image size from 26.7 MB to 9.8 MB.
2020-08-11 13:05:55 -07:00
Adrian Macneil
df461ff6c7
Add linux/arm64 build (#155) 2020-08-08 16:25:13 -07:00
Adrian Macneil
073efc996e
Update README.md (#154) 2020-08-08 12:30:22 -07:00
Adrian Macneil
24b3fccacd
Update RELEASING.md (#153) 2020-08-08 11:58:46 -07:00
Adrian Macneil
b41a73d70c
Ignore db directory (#151) 2020-08-08 11:58:25 -07:00
Adrian Macneil
9e2d1b8c3b
Allow setting flags via environment variables (#152) 2020-08-08 11:50:45 -07:00
Adrian Macneil
a9aaaad1fb
Add --url flag (#150) 2020-08-08 11:19:33 -07:00
Adrian Macneil
d1b3334ff7
Update dependencies (#149) 2020-08-07 18:45:32 -07:00
Adrian Macneil
0775179987
Update to urfave/cli v2 (#148) 2020-08-07 18:09:03 -07:00
Adrian Macneil
23aa907644
Add Homebrew release action (#147) 2020-08-07 13:45:35 -07:00
Ilia Ablamonov
c2dd1bd5af
Add ClickHouse support (#140) 2020-08-07 13:38:48 -07:00
Adrian Macneil
8234882546
v1.9.1 (#146) 2020-07-19 15:23:14 -07:00
Adrian Macneil
11c251bd25
Redact passwords in error messages (#145)
Fixes #144
2020-07-19 15:04:45 -07:00
Viswesh Periyasamy
2b61b4375a
updating version (#141) 2020-06-25 13:57:09 -07:00
Viswesh Periyasamy
24705c5d01
adding verbose output for statement execution (#138)
* adding verbose output for statement execution

* fixing lint and redefined v flag

* changing name due to inherited verbose flag and updating README

* linting

* moving verbose flag to subcommand, removing driver verbose, adding tests

* fixing README, cleaning up spacing
2020-06-25 12:26:09 -07:00
Adrian Macneil
5e128ae6a6
Update README.md (#137) 2020-05-24 20:42:33 -07:00
Nikita Konev
079523c25f Add --wait-timeout option (#127)
Closes #127
2020-05-24 19:51:36 -07:00
Adrian Macneil
ed9e57a4ad
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
2020-05-24 17:12:41 -07:00
Adrian Macneil
45a122eb86
Update README.md (#135) 2020-05-24 17:08:16 -07:00
Adrian Macneil
de0b51e623
Update dependencies (#134) 2020-05-24 15:55:32 -07:00
Adrian Macneil
1ca94e836f
Go v1.14 (#133) 2020-05-24 15:35:51 -07:00
Carlo Suriano
6cd39e1fba Support MySQL connection through unix socket (#131)
Closes #131
2020-05-24 13:00:25 -07:00
Adrian Macneil
a45d03acdb
v1.8.0 (#130) 2020-04-28 17:18:51 -07:00
Adrian Macneil
9d2ec369d8
Add --exit-code and --quiet flags to status command (#124)
Extending the `dbmate status` command with the ability to set an exit code or quiet output, for use in scripts.

Flag names were copied from `git diff` command.
2020-03-15 11:32:48 -07:00
fcarletti
256f92ad19 Add status command (#120)
Add new command to list applied and pending migrations.

Closes #28
Closes #32
Closes #66
Closes #120
2020-03-15 09:43:36 -07:00
Adrian Macneil
f7a3390299
Add make docker-bash helper (#123) 2020-03-15 08:58:05 -07:00
Adrian Macneil
882c821c1d
Add default docker postgres password (#121)
Add a default user password to fix CI failures caused by [breaking upstream change](https://github.com/docker-library/postgres/pull/658) in `postgres` docker image.

Example error: 631760202
2020-03-01 22:03:31 -08:00
Gonzalo Lucero
9a49f8ec93 Update go get install instructions to use modules
Closes #106
2020-01-02 18:45:28 +13:00
Reuben Thomas-Davis
1e45bd774c Add --wait flag (#112)
 When using dbmate as a container, since the base image is distroless, we can't do `dbmate up && dbmate wait`, which makes config a bit more cumbersome (e.g. in kubernetes an extra initContainer).

Closes #111
Closes #112
2020-01-02 18:16:16 +13:00
Adrian Macneil
98066fadaa
Stricter linting (#113) 2020-01-01 19:11:02 -10:00
thomasdziedzic-pd
810bddaea8 Update README.md (#95)
Update migrate repo to https://github.com/golang-migrate/migrate
2019-10-01 14:58:38 -07:00
Andrea Crotti
325624dbe6 Clarify that it simply uses SQL to define migrations
Closes #94
2019-09-26 09:18:21 -07:00
Adrian Macneil
e5ade066a2
v1.7.0 (#93) 2019-09-24 22:07:17 -07:00
Adrian Macneil
18ffa457d6
Automatically publish builds from Travis (#92) 2019-09-24 22:06:21 -07:00