`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).
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
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
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.
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
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. 🤔
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.
* 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