Commit graph

49 commits

Author SHA1 Message Date
Adrian Macneil
511336d346
v1.12.1 (#223) 2021-07-22 15:40:15 -07:00
Adrian Macneil
b020782b0e
v1.12.0 (#210) 2021-04-07 13:51:50 -07:00
Matt Snider
08022422d4
mysql: Fix escaping of '+' character in passwords (#200)
Fixes #199
2021-03-09 07:46:36 +00:00
Jae Bentvelzen
ece2c3c122
Improve error message when database URL is missing (#202) 2021-03-08 23:44:30 -08:00
Bouke van der Bijl
2bac2c7590
Write log lines to DB.Log output (#195)
This makes it possible to redirect the logs somewhere else, useful if you embed dbmate into your application.
2021-02-18 14:10:57 -08:00
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
c2b14bb7e0
v1.11.0 (#174) 2020-11-10 12:38:51 +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
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
616c4fe442
v1.10.0 (#158) 2020-08-13 08:30:58 -07:00
Adrian Macneil
d1b3334ff7
Update dependencies (#149) 2020-08-07 18:45:32 -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
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
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
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
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
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
Adrian Macneil
e5ade066a2
v1.7.0 (#93) 2019-09-24 22:07:17 -07:00
Adrian Macneil
b69a3d487a
Fix wait command for servers with no postgres database (#90)
Currently the `dbmate wait` command fails if the `postgres` system database does not exist (which is common on DigitalOcean, and perhaps other hosting providers).

This command is intended to verify that the postgres server is available, and not whether or not the user's database exists. Therefore, we will update this command to simply ignore the `database "foo" does not exist` error and treat this as the server being ready.

Fixes #78
2019-09-19 09:36:34 +12:00
Adrian Macneil
aa72a39a29
Cross-compile macOS and Windows builds (#89)
Adds support for cross-compiling macOS and Windows builds with cgo (using https://github.com/techknowlogick/xgo).

Closes #41
2019-09-18 22:30:59 +12:00
Adrian Macneil
5a8b38be13
v1.6.0 (#79) 2019-05-27 13:36:35 -07:00
Manuel Romei
3250277c26 Fix special chars passwords in MySQL Driver (#76)
When MySQL password included special chars such as exclamation point or @ (at), MySQL backend errored out (invalid password).

url.userinfo.String() (which gets called inside url.String()) returns %-encoded strings and MySQL interprets it as an actual password. Now the function percent-decodes it first before returning.

Closes #57
2019-05-26 10:41:54 -07:00
Ben Reinhart
c2c05ffb91
Fail statements precede up/down migration blocks (#77) 2019-05-25 12:39:21 -07:00
Ben Reinhart
02c7bda8a9
Require presence of up block; optional space after -- (#72) 2019-05-20 16:37:20 -07:00
Adrian Macneil
a31e06b438
v1.5.0 (#71) 2019-05-19 20:08:14 -07:00
Ben Reinhart
7ac46ff0f3
Add support for options; transaction option (#68)
* Add support for options; transaction option
2019-05-16 19:39:47 -07:00
Adrian Macneil
abc544b368
v1.4.1 (#51) 2018-09-03 21:39:42 -07:00
Adrian Macneil
0eabb5dc87
Postgres: Specify public schema for schema_migrations table (#52) 2018-09-03 21:33:19 -07:00
Adam Sven Johnson
7603e83f0e Postgres: Add path to schema_migrations insert statement (#49)
Since Postgres 9.6.8, at the top of the output of `pg_dump` it adds the line:

```sql
SELECT pg_catalog.set_config('search_path', '', false);
```

We must provide an absolute table reference to avoid errors when importing schema.sql.
2018-08-25 17:24:40 -07:00
Adrian Macneil
4710a35da1
Release v1.4.0 (#42) 2018-05-06 18:46:51 -07:00
Adrian Macneil
5ddcba7518
Go 1.10 (#38) 2018-04-15 20:48:22 -07:00
Adrian Macneil
28ea62eef2
Use require.NoError where appropriate (#39) 2018-04-15 20:47:24 -07:00
Adrian Macneil
ee3162c34c
Add gometalinter (#36) 2018-04-15 19:59:56 -07:00
Adrian Macneil
cacf5de3ec
Add wait command (#35) 2018-04-15 18:37:57 -07:00
Adrian Macneil
e03dec8a04 v1.3.0 2018-01-23 17:42:06 -08:00
Adrian Macneil
fbddb76b84
Add cgo build constraint for sqlite support (#25)
Required to upgrade https://github.com/mattn/go-sqlite3 which does not compile correctly with missing cgo.
2018-01-23 16:17:19 -08:00
Adrian Macneil
d855ee1ada
Add dump command (#23)
Adds `dbmate dump` command to write the database schema to a file.

The intent is for this file to be checked in to the codebase, similar to Rails' `schema.rb` (or `structure.sql`) file. This allows developers to share a single file documenting the database schema, and makes it considerably easier to review PRs which add (or change) migrations.

The existing `up`, `migrate`, and `rollback` commands will automatically trigger a schema dump, unless `--no-dump-schema` is passed.

Closes https://github.com/amacneil/dbmate/issues/5
2018-01-22 20:38:40 -08:00
Adrian Macneil
54a9fbc859
Move code into pkg directory (#22) 2018-01-07 20:12:56 -08:00