6
vendor/github.com/rubenv/sql-migrate/.gitignore
generated
vendored
Normal file
6
vendor/github.com/rubenv/sql-migrate/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
.*.swp
|
||||
*.test
|
||||
.idea
|
||||
|
||||
/sql-migrate/test.db
|
||||
/test.db
|
||||
31
vendor/github.com/rubenv/sql-migrate/.travis.yml
generated
vendored
Normal file
31
vendor/github.com/rubenv/sql-migrate/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
language: go
|
||||
|
||||
sudo: false
|
||||
|
||||
go:
|
||||
- "1.13"
|
||||
- "1.14"
|
||||
|
||||
services:
|
||||
- mysql
|
||||
- postgresql
|
||||
|
||||
before_install:
|
||||
- mysql -e "CREATE DATABASE IF NOT EXISTS test;" -uroot
|
||||
- mysql -e "CREATE DATABASE IF NOT EXISTS test_env;" -uroot
|
||||
- psql -c "CREATE DATABASE test;" -U postgres
|
||||
|
||||
install:
|
||||
- go get -t ./...
|
||||
- go install ./...
|
||||
- go get -u github.com/kisielk/errcheck
|
||||
|
||||
script:
|
||||
- CGO_ENABLED=0 go build -v .
|
||||
- go test -v ./...
|
||||
- bash test-integration/postgres.sh
|
||||
- bash test-integration/mysql.sh
|
||||
- bash test-integration/mysql-flag.sh
|
||||
- bash test-integration/mysql-env.sh
|
||||
- bash test-integration/sqlite.sh
|
||||
- errcheck ./...
|
||||
21
vendor/github.com/rubenv/sql-migrate/LICENSE
generated
vendored
Normal file
21
vendor/github.com/rubenv/sql-migrate/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2014-2019 by Ruben Vermeersch <ruben@rocketeer.be>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
400
vendor/github.com/rubenv/sql-migrate/README.md
generated
vendored
Normal file
400
vendor/github.com/rubenv/sql-migrate/README.md
generated
vendored
Normal file
@@ -0,0 +1,400 @@
|
||||
# sql-migrate
|
||||
|
||||
> SQL Schema migration tool for [Go](http://golang.org/). Based on [gorp](https://github.com/go-gorp/gorp) and [goose](https://bitbucket.org/liamstask/goose).
|
||||
|
||||
[](https://travis-ci.org/rubenv/sql-migrate) [](https://godoc.org/github.com/rubenv/sql-migrate)
|
||||
|
||||
Using [modl](https://github.com/jmoiron/modl)? Check out [modl-migrate](https://github.com/rubenv/modl-migrate).
|
||||
|
||||
## Features
|
||||
|
||||
* Usable as a CLI tool or as a library
|
||||
* Supports SQLite, PostgreSQL, MySQL, MSSQL and Oracle databases (through [gorp](https://github.com/go-gorp/gorp))
|
||||
* Can embed migrations into your application
|
||||
* Migrations are defined with SQL for full flexibility
|
||||
* Atomic migrations
|
||||
* Up/down migrations to allow rollback
|
||||
* Supports multiple database types in one project
|
||||
* Works great with other libraries such as [sqlx](http://jmoiron.github.io/sqlx/)
|
||||
|
||||
## Installation
|
||||
|
||||
To install the library and command line program, use the following:
|
||||
|
||||
```bash
|
||||
go get -v github.com/rubenv/sql-migrate/...
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### As a standalone tool
|
||||
|
||||
```
|
||||
$ sql-migrate --help
|
||||
usage: sql-migrate [--version] [--help] <command> [<args>]
|
||||
|
||||
Available commands are:
|
||||
down Undo a database migration
|
||||
new Create a new migration
|
||||
redo Reapply the last migration
|
||||
status Show migration status
|
||||
up Migrates the database to the most recent version available
|
||||
```
|
||||
|
||||
Each command requires a configuration file (which defaults to `dbconfig.yml`, but can be specified with the `-config` flag). This config file should specify one or more environments:
|
||||
|
||||
```yml
|
||||
development:
|
||||
dialect: sqlite3
|
||||
datasource: test.db
|
||||
dir: migrations/sqlite3
|
||||
|
||||
production:
|
||||
dialect: postgres
|
||||
datasource: dbname=myapp sslmode=disable
|
||||
dir: migrations/postgres
|
||||
table: migrations
|
||||
```
|
||||
|
||||
(See more examples for different set ups [here](test-integration/dbconfig.yml))
|
||||
|
||||
Also one can obtain env variables in datasource field via `os.ExpandEnv` embedded call for the field.
|
||||
This may be useful if one doesn't want to store credentials in file:
|
||||
|
||||
```yml
|
||||
production:
|
||||
dialect: postgres
|
||||
datasource: host=prodhost dbname=proddb user=${DB_USER} password=${DB_PASSWORD} sslmode=required
|
||||
dir: migrations
|
||||
table: migrations
|
||||
```
|
||||
|
||||
The `table` setting is optional and will default to `gorp_migrations`.
|
||||
|
||||
The environment that will be used can be specified with the `-env` flag (defaults to `development`).
|
||||
|
||||
Use the `--help` flag in combination with any of the commands to get an overview of its usage:
|
||||
|
||||
```
|
||||
$ sql-migrate up --help
|
||||
Usage: sql-migrate up [options] ...
|
||||
|
||||
Migrates the database to the most recent version available.
|
||||
|
||||
Options:
|
||||
|
||||
-config=dbconfig.yml Configuration file to use.
|
||||
-env="development" Environment.
|
||||
-limit=0 Limit the number of migrations (0 = unlimited).
|
||||
-dryrun Don't apply migrations, just print them.
|
||||
```
|
||||
|
||||
The `new` command creates a new empty migration template using the following pattern `<current time>-<name>.sql`.
|
||||
|
||||
The `up` command applies all available migrations. By contrast, `down` will only apply one migration by default. This behavior can be changed for both by using the `-limit` parameter.
|
||||
|
||||
The `redo` command will unapply the last migration and reapply it. This is useful during development, when you're writing migrations.
|
||||
|
||||
Use the `status` command to see the state of the applied migrations:
|
||||
|
||||
```bash
|
||||
$ sql-migrate status
|
||||
+---------------+-----------------------------------------+
|
||||
| MIGRATION | APPLIED |
|
||||
+---------------+-----------------------------------------+
|
||||
| 1_initial.sql | 2014-09-13 08:19:06.788354925 +0000 UTC |
|
||||
| 2_record.sql | no |
|
||||
+---------------+-----------------------------------------+
|
||||
```
|
||||
|
||||
#### Running Test Integrations
|
||||
You can see how to run setups for different setups by executing the `.sh` files in [test-integration](test-integration/)
|
||||
|
||||
```bash
|
||||
# Run mysql-env.sh example (you need to be in the project root directory)
|
||||
|
||||
./test-integration/mysql-env.sh
|
||||
```
|
||||
|
||||
### MySQL Caveat
|
||||
|
||||
If you are using MySQL, you must append `?parseTime=true` to the `datasource` configuration. For example:
|
||||
|
||||
```yml
|
||||
production:
|
||||
dialect: mysql
|
||||
datasource: root@/dbname?parseTime=true
|
||||
dir: migrations/mysql
|
||||
table: migrations
|
||||
```
|
||||
|
||||
See [here](https://github.com/go-sql-driver/mysql#parsetime) for more information.
|
||||
|
||||
### Oracle (oci8)
|
||||
Oracle Driver is [oci8](https://github.com/mattn/go-oci8), it is not pure Go code and relies on Oracle Office Client ([Instant Client](https://www.oracle.com/database/technologies/instant-client/downloads.html)), more detailed information is in the [oci8 repo](https://github.com/mattn/go-oci8).
|
||||
|
||||
#### Install with Oracle support
|
||||
|
||||
To install the library and command line program, use the following:
|
||||
|
||||
```bash
|
||||
go get -tags oracle -v github.com/rubenv/sql-migrate/...
|
||||
```
|
||||
|
||||
```yml
|
||||
development:
|
||||
dialect: oci8
|
||||
datasource: user/password@localhost:1521/sid
|
||||
dir: migrations/oracle
|
||||
table: migrations
|
||||
```
|
||||
|
||||
### Oracle (godror)
|
||||
Oracle Driver is [godror](https://github.com/godror/godror), it is not pure Go code and relies on Oracle Office Client ([Instant Client](https://www.oracle.com/database/technologies/instant-client/downloads.html)), more detailed information is in the [godror repository](https://github.com/godror/godror).
|
||||
|
||||
#### Install with Oracle support
|
||||
|
||||
To install the library and command line program, use the following:
|
||||
|
||||
1. Install sql-migrate
|
||||
```bash
|
||||
go get -tags godror -v github.com/rubenv/sql-migrate/...
|
||||
```
|
||||
|
||||
2. Download Oracle Office Client(e.g. macos, click [Instant Client](https://www.oracle.com/database/technologies/instant-client/downloads.html) if you are other system)
|
||||
```bash
|
||||
wget https://download.oracle.com/otn_software/mac/instantclient/193000/instantclient-basic-macos.x64-19.3.0.0.0dbru.zip
|
||||
```
|
||||
|
||||
3. Configure environment variables `LD_LIBRARY_PATH`
|
||||
```
|
||||
export LD_LIBRARY_PATH=your_oracle_office_path/instantclient_19_3
|
||||
```
|
||||
|
||||
```yml
|
||||
development:
|
||||
dialect: godror
|
||||
datasource: user/password@localhost:1521/sid
|
||||
dir: migrations/oracle
|
||||
table: migrations
|
||||
```
|
||||
|
||||
|
||||
### As a library
|
||||
|
||||
Import sql-migrate into your application:
|
||||
|
||||
```go
|
||||
import "github.com/rubenv/sql-migrate"
|
||||
```
|
||||
|
||||
Set up a source of migrations, this can be from memory, from a set of files, from bindata (more on that later), or from any library that implements [`http.FileSystem`](https://godoc.org/net/http#FileSystem):
|
||||
|
||||
```go
|
||||
// Hardcoded strings in memory:
|
||||
migrations := &migrate.MemoryMigrationSource{
|
||||
Migrations: []*migrate.Migration{
|
||||
&migrate.Migration{
|
||||
Id: "123",
|
||||
Up: []string{"CREATE TABLE people (id int)"},
|
||||
Down: []string{"DROP TABLE people"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// OR: Read migrations from a folder:
|
||||
migrations := &migrate.FileMigrationSource{
|
||||
Dir: "db/migrations",
|
||||
}
|
||||
|
||||
// OR: Use migrations from a packr box
|
||||
migrations := &migrate.PackrMigrationSource{
|
||||
Box: packr.New("migrations", "./migrations"),
|
||||
}
|
||||
|
||||
// OR: Use pkger which implements `http.FileSystem`
|
||||
migrationSource := &migrate.HttpFileSystemMigrationSource{
|
||||
FileSystem: pkger.Dir("/db/migrations"),
|
||||
}
|
||||
|
||||
// OR: Use migrations from bindata:
|
||||
migrations := &migrate.AssetMigrationSource{
|
||||
Asset: Asset,
|
||||
AssetDir: AssetDir,
|
||||
Dir: "migrations",
|
||||
}
|
||||
|
||||
// OR: Read migrations from a `http.FileSystem`
|
||||
migrationSource := &migrate.HttpFileSystemMigrationSource{
|
||||
FileSystem: httpFS,
|
||||
}
|
||||
```
|
||||
|
||||
Then use the `Exec` function to upgrade your database:
|
||||
|
||||
```go
|
||||
db, err := sql.Open("sqlite3", filename)
|
||||
if err != nil {
|
||||
// Handle errors!
|
||||
}
|
||||
|
||||
n, err := migrate.Exec(db, "sqlite3", migrations, migrate.Up)
|
||||
if err != nil {
|
||||
// Handle errors!
|
||||
}
|
||||
fmt.Printf("Applied %d migrations!\n", n)
|
||||
```
|
||||
|
||||
Note that `n` can be greater than `0` even if there is an error: any migration that succeeded will remain applied even if a later one fails.
|
||||
|
||||
Check [the GoDoc reference](https://godoc.org/github.com/rubenv/sql-migrate) for the full documentation.
|
||||
|
||||
## Writing migrations
|
||||
Migrations are defined in SQL files, which contain a set of SQL statements. Special comments are used to distinguish up and down migrations.
|
||||
|
||||
```sql
|
||||
-- +migrate Up
|
||||
-- SQL in section 'Up' is executed when this migration is applied
|
||||
CREATE TABLE people (id int);
|
||||
|
||||
|
||||
-- +migrate Down
|
||||
-- SQL section 'Down' is executed when this migration is rolled back
|
||||
DROP TABLE people;
|
||||
```
|
||||
|
||||
You can put multiple statements in each block, as long as you end them with a semicolon (`;`).
|
||||
|
||||
You can alternatively set up a separator string that matches an entire line by setting `sqlparse.LineSeparator`. This
|
||||
can be used to imitate, for example, MS SQL Query Analyzer functionality where commands can be separated by a line with
|
||||
contents of `GO`. If `sqlparse.LineSeparator` is matched, it will not be included in the resulting migration scripts.
|
||||
|
||||
If you have complex statements which contain semicolons, use `StatementBegin` and `StatementEnd` to indicate boundaries:
|
||||
|
||||
```sql
|
||||
-- +migrate Up
|
||||
CREATE TABLE people (id int);
|
||||
|
||||
-- +migrate StatementBegin
|
||||
CREATE OR REPLACE FUNCTION do_something()
|
||||
returns void AS $$
|
||||
DECLARE
|
||||
create_query text;
|
||||
BEGIN
|
||||
-- Do something here
|
||||
END;
|
||||
$$
|
||||
language plpgsql;
|
||||
-- +migrate StatementEnd
|
||||
|
||||
-- +migrate Down
|
||||
DROP FUNCTION do_something();
|
||||
DROP TABLE people;
|
||||
```
|
||||
|
||||
The order in which migrations are applied is defined through the filename: sql-migrate will sort migrations based on their name. It's recommended to use an increasing version number or a timestamp as the first part of the filename.
|
||||
|
||||
Normally each migration is run within a transaction in order to guarantee that it is fully atomic. However some SQL commands (for example creating an index concurrently in PostgreSQL) cannot be executed inside a transaction. In order to execute such a command in a migration, the migration can be run using the `notransaction` option:
|
||||
|
||||
```sql
|
||||
-- +migrate Up notransaction
|
||||
CREATE UNIQUE INDEX people_unique_id_idx CONCURRENTLY ON people (id);
|
||||
|
||||
-- +migrate Down
|
||||
DROP INDEX people_unique_id_idx;
|
||||
```
|
||||
|
||||
## Embedding migrations with [packr](https://github.com/gobuffalo/packr)
|
||||
|
||||
If you like your Go applications self-contained (that is: a single binary): use [packr](https://github.com/gobuffalo/packr) to embed the migration files.
|
||||
|
||||
Just write your migration files as usual, as a set of SQL files in a folder.
|
||||
|
||||
Import the packr package into your application:
|
||||
|
||||
```go
|
||||
import "github.com/gobuffalo/packr/v2"
|
||||
```
|
||||
|
||||
Use the `PackrMigrationSource` in your application to find the migrations:
|
||||
|
||||
```go
|
||||
migrations := &migrate.PackrMigrationSource{
|
||||
Box: packr.New("migrations", "./migrations"),
|
||||
}
|
||||
```
|
||||
|
||||
If you already have a box and would like to use a subdirectory:
|
||||
|
||||
```go
|
||||
migrations := &migrate.PackrMigrationSource{
|
||||
Box: myBox,
|
||||
Dir: "./migrations",
|
||||
}
|
||||
```
|
||||
|
||||
## Embedding migrations with [bindata](https://github.com/shuLhan/go-bindata)
|
||||
|
||||
As an alternative, but slightly less maintained, you can use [bindata](https://github.com/shuLhan/go-bindata) to embed the migration files.
|
||||
|
||||
Just write your migration files as usual, as a set of SQL files in a folder.
|
||||
|
||||
Then use bindata to generate a `.go` file with the migrations embedded:
|
||||
|
||||
```bash
|
||||
go-bindata -pkg myapp -o bindata.go db/migrations/
|
||||
```
|
||||
|
||||
The resulting `bindata.go` file will contain your migrations. Remember to regenerate your `bindata.go` file whenever you add/modify a migration (`go generate` will help here, once it arrives).
|
||||
|
||||
Use the `AssetMigrationSource` in your application to find the migrations:
|
||||
|
||||
```go
|
||||
migrations := &migrate.AssetMigrationSource{
|
||||
Asset: Asset,
|
||||
AssetDir: AssetDir,
|
||||
Dir: "db/migrations",
|
||||
}
|
||||
```
|
||||
|
||||
Both `Asset` and `AssetDir` are functions provided by bindata.
|
||||
|
||||
Then proceed as usual.
|
||||
|
||||
## Embedding migrations with libraries that implement `http.FileSystem`
|
||||
|
||||
You can also embed migrations with any library that implements `http.FileSystem`, like [`vfsgen`](https://github.com/shurcooL/vfsgen), [`parcello`](https://github.com/phogolabs/parcello), or [`go-resources`](https://github.com/omeid/go-resources).
|
||||
|
||||
```go
|
||||
migrationSource := &migrate.HttpFileSystemMigrationSource{
|
||||
FileSystem: httpFS,
|
||||
}
|
||||
```
|
||||
|
||||
## Extending
|
||||
|
||||
Adding a new migration source means implementing `MigrationSource`.
|
||||
|
||||
```go
|
||||
type MigrationSource interface {
|
||||
FindMigrations() ([]*Migration, error)
|
||||
}
|
||||
```
|
||||
|
||||
The resulting slice of migrations will be executed in the given order, so it should usually be sorted by the `Id` field.
|
||||
|
||||
## Usage with [sqlx](http://jmoiron.github.io/sqlx/)
|
||||
|
||||
This library is compatible with sqlx. When calling migrate just dereference the DB from your `*sqlx.DB`:
|
||||
|
||||
```
|
||||
n, err := migrate.Exec(db.DB, "sqlite3", migrations, migrate.Up)
|
||||
// ^^^ <-- Here db is a *sqlx.DB, the db.DB field is the plain sql.DB
|
||||
if err != nil {
|
||||
// Handle errors!
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
This library is distributed under the [MIT](LICENSE) license.
|
||||
239
vendor/github.com/rubenv/sql-migrate/doc.go
generated
vendored
Normal file
239
vendor/github.com/rubenv/sql-migrate/doc.go
generated
vendored
Normal file
@@ -0,0 +1,239 @@
|
||||
/*
|
||||
|
||||
SQL Schema migration tool for Go.
|
||||
|
||||
Key features:
|
||||
|
||||
* Usable as a CLI tool or as a library
|
||||
* Supports SQLite, PostgreSQL, MySQL, MSSQL and Oracle databases (through gorp)
|
||||
* Can embed migrations into your application
|
||||
* Migrations are defined with SQL for full flexibility
|
||||
* Atomic migrations
|
||||
* Up/down migrations to allow rollback
|
||||
* Supports multiple database types in one project
|
||||
|
||||
Installation
|
||||
|
||||
To install the library and command line program, use the following:
|
||||
|
||||
go get -v github.com/rubenv/sql-migrate/...
|
||||
|
||||
Command-line tool
|
||||
|
||||
The main command is called sql-migrate.
|
||||
|
||||
$ sql-migrate --help
|
||||
usage: sql-migrate [--version] [--help] <command> [<args>]
|
||||
|
||||
Available commands are:
|
||||
down Undo a database migration
|
||||
new Create a new migration
|
||||
redo Reapply the last migration
|
||||
status Show migration status
|
||||
up Migrates the database to the most recent version available
|
||||
|
||||
Each command requires a configuration file (which defaults to dbconfig.yml, but can be specified with the -config flag). This config file should specify one or more environments:
|
||||
|
||||
development:
|
||||
dialect: sqlite3
|
||||
datasource: test.db
|
||||
dir: migrations/sqlite3
|
||||
|
||||
production:
|
||||
dialect: postgres
|
||||
datasource: dbname=myapp sslmode=disable
|
||||
dir: migrations/postgres
|
||||
table: migrations
|
||||
|
||||
The `table` setting is optional and will default to `gorp_migrations`.
|
||||
|
||||
The environment that will be used can be specified with the -env flag (defaults to development).
|
||||
|
||||
Use the --help flag in combination with any of the commands to get an overview of its usage:
|
||||
|
||||
$ sql-migrate up --help
|
||||
Usage: sql-migrate up [options] ...
|
||||
|
||||
Migrates the database to the most recent version available.
|
||||
|
||||
Options:
|
||||
|
||||
-config=config.yml Configuration file to use.
|
||||
-env="development" Environment.
|
||||
-limit=0 Limit the number of migrations (0 = unlimited).
|
||||
-dryrun Don't apply migrations, just print them.
|
||||
|
||||
The up command applies all available migrations. By contrast, down will only apply one migration by default. This behavior can be changed for both by using the -limit parameter.
|
||||
|
||||
The redo command will unapply the last migration and reapply it. This is useful during development, when you're writing migrations.
|
||||
|
||||
Use the status command to see the state of the applied migrations:
|
||||
|
||||
$ sql-migrate status
|
||||
+---------------+-----------------------------------------+
|
||||
| MIGRATION | APPLIED |
|
||||
+---------------+-----------------------------------------+
|
||||
| 1_initial.sql | 2014-09-13 08:19:06.788354925 +0000 UTC |
|
||||
| 2_record.sql | no |
|
||||
+---------------+-----------------------------------------+
|
||||
|
||||
MySQL Caveat
|
||||
|
||||
If you are using MySQL, you must append ?parseTime=true to the datasource configuration. For example:
|
||||
|
||||
production:
|
||||
dialect: mysql
|
||||
datasource: root@/dbname?parseTime=true
|
||||
dir: migrations/mysql
|
||||
table: migrations
|
||||
|
||||
See https://github.com/go-sql-driver/mysql#parsetime for more information.
|
||||
|
||||
Library
|
||||
|
||||
Import sql-migrate into your application:
|
||||
|
||||
import "github.com/rubenv/sql-migrate"
|
||||
|
||||
Set up a source of migrations, this can be from memory, from a set of files or from bindata (more on that later):
|
||||
|
||||
// Hardcoded strings in memory:
|
||||
migrations := &migrate.MemoryMigrationSource{
|
||||
Migrations: []*migrate.Migration{
|
||||
&migrate.Migration{
|
||||
Id: "123",
|
||||
Up: []string{"CREATE TABLE people (id int)"},
|
||||
Down: []string{"DROP TABLE people"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// OR: Read migrations from a folder:
|
||||
migrations := &migrate.FileMigrationSource{
|
||||
Dir: "db/migrations",
|
||||
}
|
||||
|
||||
// OR: Use migrations from bindata:
|
||||
migrations := &migrate.AssetMigrationSource{
|
||||
Asset: Asset,
|
||||
AssetDir: AssetDir,
|
||||
Dir: "migrations",
|
||||
}
|
||||
|
||||
Then use the Exec function to upgrade your database:
|
||||
|
||||
db, err := sql.Open("sqlite3", filename)
|
||||
if err != nil {
|
||||
// Handle errors!
|
||||
}
|
||||
|
||||
n, err := migrate.Exec(db, "sqlite3", migrations, migrate.Up)
|
||||
if err != nil {
|
||||
// Handle errors!
|
||||
}
|
||||
fmt.Printf("Applied %d migrations!\n", n)
|
||||
|
||||
Note that n can be greater than 0 even if there is an error: any migration that succeeded will remain applied even if a later one fails.
|
||||
|
||||
The full set of capabilities can be found in the API docs below.
|
||||
|
||||
Writing migrations
|
||||
|
||||
Migrations are defined in SQL files, which contain a set of SQL statements. Special comments are used to distinguish up and down migrations.
|
||||
|
||||
-- +migrate Up
|
||||
-- SQL in section 'Up' is executed when this migration is applied
|
||||
CREATE TABLE people (id int);
|
||||
|
||||
|
||||
-- +migrate Down
|
||||
-- SQL section 'Down' is executed when this migration is rolled back
|
||||
DROP TABLE people;
|
||||
|
||||
You can put multiple statements in each block, as long as you end them with a semicolon (;).
|
||||
|
||||
If you have complex statements which contain semicolons, use StatementBegin and StatementEnd to indicate boundaries:
|
||||
|
||||
-- +migrate Up
|
||||
CREATE TABLE people (id int);
|
||||
|
||||
-- +migrate StatementBegin
|
||||
CREATE OR REPLACE FUNCTION do_something()
|
||||
returns void AS $$
|
||||
DECLARE
|
||||
create_query text;
|
||||
BEGIN
|
||||
-- Do something here
|
||||
END;
|
||||
$$
|
||||
language plpgsql;
|
||||
-- +migrate StatementEnd
|
||||
|
||||
-- +migrate Down
|
||||
DROP FUNCTION do_something();
|
||||
DROP TABLE people;
|
||||
|
||||
The order in which migrations are applied is defined through the filename: sql-migrate will sort migrations based on their name. It's recommended to use an increasing version number or a timestamp as the first part of the filename.
|
||||
|
||||
Normally each migration is run within a transaction in order to guarantee that it is fully atomic. However some SQL commands (for example creating an index concurrently in PostgreSQL) cannot be executed inside a transaction. In order to execute such a command in a migration, the migration can be run using the notransaction option:
|
||||
|
||||
-- +migrate Up notransaction
|
||||
CREATE UNIQUE INDEX people_unique_id_idx CONCURRENTLY ON people (id);
|
||||
|
||||
-- +migrate Down
|
||||
DROP INDEX people_unique_id_idx;
|
||||
|
||||
Embedding migrations with packr
|
||||
|
||||
If you like your Go applications self-contained (that is: a single binary): use packr (https://github.com/gobuffalo/packr) to embed the migration files.
|
||||
|
||||
Just write your migration files as usual, as a set of SQL files in a folder.
|
||||
|
||||
Use the PackrMigrationSource in your application to find the migrations:
|
||||
|
||||
migrations := &migrate.PackrMigrationSource{
|
||||
Box: packr.NewBox("./migrations"),
|
||||
}
|
||||
|
||||
If you already have a box and would like to use a subdirectory:
|
||||
|
||||
migrations := &migrate.PackrMigrationSource{
|
||||
Box: myBox,
|
||||
Dir: "./migrations",
|
||||
}
|
||||
|
||||
Embedding migrations with bindata
|
||||
|
||||
As an alternative, but slightly less maintained, you can use bindata (https://github.com/shuLhan/go-bindata) to embed the migration files.
|
||||
|
||||
Just write your migration files as usual, as a set of SQL files in a folder.
|
||||
|
||||
Then use bindata to generate a .go file with the migrations embedded:
|
||||
|
||||
go-bindata -pkg myapp -o bindata.go db/migrations/
|
||||
|
||||
The resulting bindata.go file will contain your migrations. Remember to regenerate your bindata.go file whenever you add/modify a migration (go generate will help here, once it arrives).
|
||||
|
||||
Use the AssetMigrationSource in your application to find the migrations:
|
||||
|
||||
migrations := &migrate.AssetMigrationSource{
|
||||
Asset: Asset,
|
||||
AssetDir: AssetDir,
|
||||
Dir: "db/migrations",
|
||||
}
|
||||
|
||||
Both Asset and AssetDir are functions provided by bindata.
|
||||
|
||||
Then proceed as usual.
|
||||
|
||||
Extending
|
||||
|
||||
Adding a new migration source means implementing MigrationSource.
|
||||
|
||||
type MigrationSource interface {
|
||||
FindMigrations() ([]*Migration, error)
|
||||
}
|
||||
|
||||
The resulting slice of migrations will be executed in the given order, so it should usually be sorted by the Id field.
|
||||
*/
|
||||
package migrate
|
||||
20
vendor/github.com/rubenv/sql-migrate/go.mod
generated
vendored
Normal file
20
vendor/github.com/rubenv/sql-migrate/go.mod
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
module github.com/rubenv/sql-migrate
|
||||
|
||||
go 1.11
|
||||
|
||||
require (
|
||||
github.com/denisenkom/go-mssqldb v0.0.0-20191001013358-cfbb681360f0
|
||||
github.com/go-sql-driver/mysql v1.4.1
|
||||
github.com/gobuffalo/packr/v2 v2.7.1
|
||||
github.com/godror/godror v0.13.3
|
||||
github.com/lib/pq v1.2.0
|
||||
github.com/mattn/go-oci8 v0.0.7
|
||||
github.com/mattn/go-sqlite3 v1.12.0
|
||||
github.com/mitchellh/cli v1.0.0
|
||||
github.com/olekukonko/tablewriter v0.0.2
|
||||
github.com/ziutek/mymysql v1.5.4 // indirect
|
||||
google.golang.org/appengine v1.6.5 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127
|
||||
gopkg.in/gorp.v1 v1.7.2
|
||||
gopkg.in/yaml.v2 v2.2.5
|
||||
)
|
||||
418
vendor/github.com/rubenv/sql-migrate/go.sum
generated
vendored
Normal file
418
vendor/github.com/rubenv/sql-migrate/go.sum
generated
vendored
Normal file
@@ -0,0 +1,418 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
||||
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
||||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
||||
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
|
||||
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
|
||||
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
||||
github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A=
|
||||
github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
|
||||
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
|
||||
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
|
||||
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
|
||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/denisenkom/go-mssqldb v0.0.0-20191001013358-cfbb681360f0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
|
||||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
|
||||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
||||
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
|
||||
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
|
||||
github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.10.0 h1:dXFJfIHVvUcpSgDOV+Ne6t7jXri8Tfv2uOLHUZ2XNuo=
|
||||
github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-logfmt/logfmt v0.5.0 h1:TrB8swr/68K7m9CcGut2g3UOihhbcbiMAYiuTXdEih4=
|
||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=
|
||||
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI=
|
||||
github.com/gobuffalo/envy v1.7.1/go.mod h1:FurDp9+EDPE4aIUS3ZLyD+7/9fpx7YRt/ukY6jIHf0w=
|
||||
github.com/gobuffalo/logger v1.0.1/go.mod h1:2zbswyIUa45I+c+FLXuWl9zSWEiVuthsk8ze5s8JvPs=
|
||||
github.com/gobuffalo/packd v0.3.0 h1:eMwymTkA1uXsqxS0Tpoop3Lc0u3kTfiMBE6nKtQU4g4=
|
||||
github.com/gobuffalo/packd v0.3.0/go.mod h1:zC7QkmNkYVGKPw4tHpBQ+ml7W/3tIebgeo1b36chA3Q=
|
||||
github.com/gobuffalo/packr/v2 v2.7.1/go.mod h1:qYEvAazPaVxy7Y7KR0W8qYEE+RymX74kETFqjFoFlOc=
|
||||
github.com/godror/godror v0.13.3 h1:4A5GLGAJTSuELw1NThqY5bINYB+mqrln+kF5C2vuyCs=
|
||||
github.com/godror/godror v0.13.3/go.mod h1:2ouUT4kdhUBk7TAkHWD4SN0CdI0pgEQbo8FVHhbSKWg=
|
||||
github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||
github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE=
|
||||
github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
|
||||
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
|
||||
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
|
||||
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
||||
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
|
||||
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
|
||||
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
|
||||
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
||||
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
|
||||
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
|
||||
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
|
||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
|
||||
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
|
||||
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
|
||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-oci8 v0.0.7 h1:BBXYpvzPO43QNTLDEivPFteeFZ9nKA6JQ6eifpxOmio=
|
||||
github.com/mattn/go-oci8 v0.0.7/go.mod h1:wjDx6Xm9q7dFtHJvIlrI99JytznLw5wQ4R+9mNXJwGI=
|
||||
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
github.com/mattn/go-sqlite3 v1.12.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
|
||||
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
|
||||
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
|
||||
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
|
||||
github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU=
|
||||
github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k=
|
||||
github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w=
|
||||
github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
|
||||
github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
|
||||
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||
github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
|
||||
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
|
||||
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
|
||||
github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
|
||||
github.com/olekukonko/tablewriter v0.0.2/go.mod h1:rSAaSIOAGT9odnlyGlUfAJaoc5w2fSBUmeGDbRWPxyQ=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
|
||||
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis=
|
||||
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
|
||||
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||
github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA=
|
||||
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
|
||||
github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
|
||||
github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
|
||||
github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM=
|
||||
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac=
|
||||
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
|
||||
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.3.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/rogpeppe/go-internal v1.4.0/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
|
||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||
github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
|
||||
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
|
||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
||||
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
||||
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||
github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs=
|
||||
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
|
||||
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg=
|
||||
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
|
||||
go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
|
||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
|
||||
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
|
||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190515120540-06a5c4944438/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191220142924-d4481acd189f h1:68K/z8GLUxV76xGSqwTWw2gyk/jwn79LUL43rES2g8o=
|
||||
golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20191004055002-72853e10c5a3/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM=
|
||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
|
||||
gopkg.in/gorp.v1 v1.7.2 h1:j3DWlAyGVv8whO7AcIWznQ2Yj7yJkn34B8s63GViAAw=
|
||||
gopkg.in/gorp.v1 v1.7.2/go.mod h1:Wo3h+DBQZIxATwftsglhdD/62zRFPhGhTiu5jUJmCaw=
|
||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
|
||||
768
vendor/github.com/rubenv/sql-migrate/migrate.go
generated
vendored
Normal file
768
vendor/github.com/rubenv/sql-migrate/migrate.go
generated
vendored
Normal file
@@ -0,0 +1,768 @@
|
||||
package migrate
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/rubenv/sql-migrate/sqlparse"
|
||||
"gopkg.in/gorp.v1"
|
||||
)
|
||||
|
||||
type MigrationDirection int
|
||||
|
||||
const (
|
||||
Up MigrationDirection = iota
|
||||
Down
|
||||
)
|
||||
|
||||
// MigrationSet provides database parameters for a migration execution
|
||||
type MigrationSet struct {
|
||||
// TableName name of the table used to store migration info.
|
||||
TableName string
|
||||
// SchemaName schema that the migration table be referenced.
|
||||
SchemaName string
|
||||
// IgnoreUnknown skips the check to see if there is a migration
|
||||
// ran in the database that is not in MigrationSource.
|
||||
//
|
||||
// This should be used sparingly as it is removing a safety check.
|
||||
IgnoreUnknown bool
|
||||
}
|
||||
|
||||
var migSet = MigrationSet{}
|
||||
|
||||
// NewMigrationSet returns a parametrized Migration object
|
||||
func (ms MigrationSet) getTableName() string {
|
||||
if ms.TableName == "" {
|
||||
return "gorp_migrations"
|
||||
}
|
||||
return ms.TableName
|
||||
}
|
||||
|
||||
var numberPrefixRegex = regexp.MustCompile(`^(\d+).*$`)
|
||||
|
||||
// PlanError happens where no migration plan could be created between the sets
|
||||
// of already applied migrations and the currently found. For example, when the database
|
||||
// contains a migration which is not among the migrations list found for an operation.
|
||||
type PlanError struct {
|
||||
Migration *Migration
|
||||
ErrorMessage string
|
||||
}
|
||||
|
||||
func newPlanError(migration *Migration, errorMessage string) error {
|
||||
return &PlanError{
|
||||
Migration: migration,
|
||||
ErrorMessage: errorMessage,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *PlanError) Error() string {
|
||||
return fmt.Sprintf("Unable to create migration plan because of %s: %s",
|
||||
p.Migration.Id, p.ErrorMessage)
|
||||
}
|
||||
|
||||
// TxError is returned when any error is encountered during a database
|
||||
// transaction. It contains the relevant *Migration and notes it's Id in the
|
||||
// Error function output.
|
||||
type TxError struct {
|
||||
Migration *Migration
|
||||
Err error
|
||||
}
|
||||
|
||||
func newTxError(migration *PlannedMigration, err error) error {
|
||||
return &TxError{
|
||||
Migration: migration.Migration,
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *TxError) Error() string {
|
||||
return e.Err.Error() + " handling " + e.Migration.Id
|
||||
}
|
||||
|
||||
// Set the name of the table used to store migration info.
|
||||
//
|
||||
// Should be called before any other call such as (Exec, ExecMax, ...).
|
||||
func SetTable(name string) {
|
||||
if name != "" {
|
||||
migSet.TableName = name
|
||||
}
|
||||
}
|
||||
|
||||
// SetSchema sets the name of a schema that the migration table be referenced.
|
||||
func SetSchema(name string) {
|
||||
if name != "" {
|
||||
migSet.SchemaName = name
|
||||
}
|
||||
}
|
||||
|
||||
// SetIgnoreUnknown sets the flag that skips database check to see if there is a
|
||||
// migration in the database that is not in migration source.
|
||||
//
|
||||
// This should be used sparingly as it is removing a safety check.
|
||||
func SetIgnoreUnknown(v bool) {
|
||||
migSet.IgnoreUnknown = v
|
||||
}
|
||||
|
||||
type Migration struct {
|
||||
Id string
|
||||
Up []string
|
||||
Down []string
|
||||
|
||||
DisableTransactionUp bool
|
||||
DisableTransactionDown bool
|
||||
}
|
||||
|
||||
func (m Migration) Less(other *Migration) bool {
|
||||
switch {
|
||||
case m.isNumeric() && other.isNumeric() && m.VersionInt() != other.VersionInt():
|
||||
return m.VersionInt() < other.VersionInt()
|
||||
case m.isNumeric() && !other.isNumeric():
|
||||
return true
|
||||
case !m.isNumeric() && other.isNumeric():
|
||||
return false
|
||||
default:
|
||||
return m.Id < other.Id
|
||||
}
|
||||
}
|
||||
|
||||
func (m Migration) isNumeric() bool {
|
||||
return len(m.NumberPrefixMatches()) > 0
|
||||
}
|
||||
|
||||
func (m Migration) NumberPrefixMatches() []string {
|
||||
return numberPrefixRegex.FindStringSubmatch(m.Id)
|
||||
}
|
||||
|
||||
func (m Migration) VersionInt() int64 {
|
||||
v := m.NumberPrefixMatches()[1]
|
||||
value, err := strconv.ParseInt(v, 10, 64)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("Could not parse %q into int64: %s", v, err))
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
type PlannedMigration struct {
|
||||
*Migration
|
||||
|
||||
DisableTransaction bool
|
||||
Queries []string
|
||||
}
|
||||
|
||||
type byId []*Migration
|
||||
|
||||
func (b byId) Len() int { return len(b) }
|
||||
func (b byId) Swap(i, j int) { b[i], b[j] = b[j], b[i] }
|
||||
func (b byId) Less(i, j int) bool { return b[i].Less(b[j]) }
|
||||
|
||||
type MigrationRecord struct {
|
||||
Id string `db:"id"`
|
||||
AppliedAt time.Time `db:"applied_at"`
|
||||
}
|
||||
|
||||
type OracleDialect struct {
|
||||
gorp.OracleDialect
|
||||
}
|
||||
|
||||
func (d OracleDialect) IfTableNotExists(command, schema, table string) string {
|
||||
return command
|
||||
}
|
||||
|
||||
func (d OracleDialect) IfSchemaNotExists(command, schema string) string {
|
||||
return command
|
||||
}
|
||||
|
||||
func (d OracleDialect) IfTableExists(command, schema, table string) string {
|
||||
return command
|
||||
}
|
||||
|
||||
var MigrationDialects = map[string]gorp.Dialect{
|
||||
"sqlite3": gorp.SqliteDialect{},
|
||||
"postgres": gorp.PostgresDialect{},
|
||||
"mysql": gorp.MySQLDialect{Engine: "InnoDB", Encoding: "UTF8"},
|
||||
"mssql": gorp.SqlServerDialect{},
|
||||
"oci8": OracleDialect{},
|
||||
"godror": OracleDialect{},
|
||||
}
|
||||
|
||||
type MigrationSource interface {
|
||||
// Finds the migrations.
|
||||
//
|
||||
// The resulting slice of migrations should be sorted by Id.
|
||||
FindMigrations() ([]*Migration, error)
|
||||
}
|
||||
|
||||
// A hardcoded set of migrations, in-memory.
|
||||
type MemoryMigrationSource struct {
|
||||
Migrations []*Migration
|
||||
}
|
||||
|
||||
var _ MigrationSource = (*MemoryMigrationSource)(nil)
|
||||
|
||||
func (m MemoryMigrationSource) FindMigrations() ([]*Migration, error) {
|
||||
// Make sure migrations are sorted. In order to make the MemoryMigrationSource safe for
|
||||
// concurrent use we should not mutate it in place. So `FindMigrations` would sort a copy
|
||||
// of the m.Migrations.
|
||||
migrations := make([]*Migration, len(m.Migrations))
|
||||
copy(migrations, m.Migrations)
|
||||
sort.Sort(byId(migrations))
|
||||
return migrations, nil
|
||||
}
|
||||
|
||||
// A set of migrations loaded from an http.FileServer
|
||||
|
||||
type HttpFileSystemMigrationSource struct {
|
||||
FileSystem http.FileSystem
|
||||
}
|
||||
|
||||
var _ MigrationSource = (*HttpFileSystemMigrationSource)(nil)
|
||||
|
||||
func (f HttpFileSystemMigrationSource) FindMigrations() ([]*Migration, error) {
|
||||
return findMigrations(f.FileSystem)
|
||||
}
|
||||
|
||||
// A set of migrations loaded from a directory.
|
||||
type FileMigrationSource struct {
|
||||
Dir string
|
||||
}
|
||||
|
||||
var _ MigrationSource = (*FileMigrationSource)(nil)
|
||||
|
||||
func (f FileMigrationSource) FindMigrations() ([]*Migration, error) {
|
||||
filesystem := http.Dir(f.Dir)
|
||||
return findMigrations(filesystem)
|
||||
}
|
||||
|
||||
func findMigrations(dir http.FileSystem) ([]*Migration, error) {
|
||||
migrations := make([]*Migration, 0)
|
||||
|
||||
file, err := dir.Open("/")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
files, err := file.Readdir(0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, info := range files {
|
||||
if strings.HasSuffix(info.Name(), ".sql") {
|
||||
migration, err := migrationFromFile(dir, info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
migrations = append(migrations, migration)
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure migrations are sorted
|
||||
sort.Sort(byId(migrations))
|
||||
|
||||
return migrations, nil
|
||||
}
|
||||
|
||||
func migrationFromFile(dir http.FileSystem, info os.FileInfo) (*Migration, error) {
|
||||
path := fmt.Sprintf("/%s", strings.TrimPrefix(info.Name(), "/"))
|
||||
file, err := dir.Open(path)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error while opening %s: %s", info.Name(), err)
|
||||
}
|
||||
defer func() { _ = file.Close() }()
|
||||
|
||||
migration, err := ParseMigration(info.Name(), file)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error while parsing %s: %s", info.Name(), err)
|
||||
}
|
||||
return migration, nil
|
||||
}
|
||||
|
||||
// Migrations from a bindata asset set.
|
||||
type AssetMigrationSource struct {
|
||||
// Asset should return content of file in path if exists
|
||||
Asset func(path string) ([]byte, error)
|
||||
|
||||
// AssetDir should return list of files in the path
|
||||
AssetDir func(path string) ([]string, error)
|
||||
|
||||
// Path in the bindata to use.
|
||||
Dir string
|
||||
}
|
||||
|
||||
var _ MigrationSource = (*AssetMigrationSource)(nil)
|
||||
|
||||
func (a AssetMigrationSource) FindMigrations() ([]*Migration, error) {
|
||||
migrations := make([]*Migration, 0)
|
||||
|
||||
files, err := a.AssetDir(a.Dir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, name := range files {
|
||||
if strings.HasSuffix(name, ".sql") {
|
||||
file, err := a.Asset(path.Join(a.Dir, name))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
migration, err := ParseMigration(name, bytes.NewReader(file))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
migrations = append(migrations, migration)
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure migrations are sorted
|
||||
sort.Sort(byId(migrations))
|
||||
|
||||
return migrations, nil
|
||||
}
|
||||
|
||||
// Avoids pulling in the packr library for everyone, mimicks the bits of
|
||||
// packr.Box that we need.
|
||||
type PackrBox interface {
|
||||
List() []string
|
||||
Find(name string) ([]byte, error)
|
||||
}
|
||||
|
||||
// Migrations from a packr box.
|
||||
type PackrMigrationSource struct {
|
||||
Box PackrBox
|
||||
|
||||
// Path in the box to use.
|
||||
Dir string
|
||||
}
|
||||
|
||||
var _ MigrationSource = (*PackrMigrationSource)(nil)
|
||||
|
||||
func (p PackrMigrationSource) FindMigrations() ([]*Migration, error) {
|
||||
migrations := make([]*Migration, 0)
|
||||
items := p.Box.List()
|
||||
|
||||
prefix := ""
|
||||
dir := path.Clean(p.Dir)
|
||||
if dir != "." {
|
||||
prefix = fmt.Sprintf("%s/", dir)
|
||||
}
|
||||
|
||||
for _, item := range items {
|
||||
if !strings.HasPrefix(item, prefix) {
|
||||
continue
|
||||
}
|
||||
name := strings.TrimPrefix(item, prefix)
|
||||
if strings.Contains(name, "/") {
|
||||
continue
|
||||
}
|
||||
|
||||
if strings.HasSuffix(name, ".sql") {
|
||||
file, err := p.Box.Find(item)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
migration, err := ParseMigration(name, bytes.NewReader(file))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
migrations = append(migrations, migration)
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure migrations are sorted
|
||||
sort.Sort(byId(migrations))
|
||||
|
||||
return migrations, nil
|
||||
}
|
||||
|
||||
// Migration parsing
|
||||
func ParseMigration(id string, r io.ReadSeeker) (*Migration, error) {
|
||||
m := &Migration{
|
||||
Id: id,
|
||||
}
|
||||
|
||||
parsed, err := sqlparse.ParseMigration(r)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error parsing migration (%s): %s", id, err)
|
||||
}
|
||||
|
||||
m.Up = parsed.UpStatements
|
||||
m.Down = parsed.DownStatements
|
||||
|
||||
m.DisableTransactionUp = parsed.DisableTransactionUp
|
||||
m.DisableTransactionDown = parsed.DisableTransactionDown
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
type SqlExecutor interface {
|
||||
Exec(query string, args ...interface{}) (sql.Result, error)
|
||||
Insert(list ...interface{}) error
|
||||
Delete(list ...interface{}) (int64, error)
|
||||
}
|
||||
|
||||
// Execute a set of migrations
|
||||
//
|
||||
// Returns the number of applied migrations.
|
||||
func Exec(db *sql.DB, dialect string, m MigrationSource, dir MigrationDirection) (int, error) {
|
||||
return ExecMax(db, dialect, m, dir, 0)
|
||||
}
|
||||
|
||||
// Returns the number of applied migrations.
|
||||
func (ms MigrationSet) Exec(db *sql.DB, dialect string, m MigrationSource, dir MigrationDirection) (int, error) {
|
||||
return ms.ExecMax(db, dialect, m, dir, 0)
|
||||
}
|
||||
|
||||
// Execute a set of migrations
|
||||
//
|
||||
// Will apply at most `max` migrations. Pass 0 for no limit (or use Exec).
|
||||
//
|
||||
// Returns the number of applied migrations.
|
||||
func ExecMax(db *sql.DB, dialect string, m MigrationSource, dir MigrationDirection, max int) (int, error) {
|
||||
return migSet.ExecMax(db, dialect, m, dir, max)
|
||||
}
|
||||
|
||||
// Returns the number of applied migrations.
|
||||
func (ms MigrationSet) ExecMax(db *sql.DB, dialect string, m MigrationSource, dir MigrationDirection, max int) (int, error) {
|
||||
migrations, dbMap, err := ms.PlanMigration(db, dialect, m, dir, max)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Apply migrations
|
||||
applied := 0
|
||||
for _, migration := range migrations {
|
||||
var executor SqlExecutor
|
||||
|
||||
if migration.DisableTransaction {
|
||||
executor = dbMap
|
||||
} else {
|
||||
executor, err = dbMap.Begin()
|
||||
if err != nil {
|
||||
return applied, newTxError(migration, err)
|
||||
}
|
||||
}
|
||||
|
||||
for _, stmt := range migration.Queries {
|
||||
// remove the semicolon from stmt, fix ORA-00922 issue in database oracle
|
||||
stmt = strings.TrimSuffix(stmt, "\n")
|
||||
stmt = strings.TrimSuffix(stmt, " ")
|
||||
stmt = strings.TrimSuffix(stmt, ";")
|
||||
if _, err := executor.Exec(stmt); err != nil {
|
||||
if trans, ok := executor.(*gorp.Transaction); ok {
|
||||
_ = trans.Rollback()
|
||||
}
|
||||
|
||||
return applied, newTxError(migration, err)
|
||||
}
|
||||
}
|
||||
|
||||
switch dir {
|
||||
case Up:
|
||||
err = executor.Insert(&MigrationRecord{
|
||||
Id: migration.Id,
|
||||
AppliedAt: time.Now(),
|
||||
})
|
||||
if err != nil {
|
||||
if trans, ok := executor.(*gorp.Transaction); ok {
|
||||
_ = trans.Rollback()
|
||||
}
|
||||
|
||||
return applied, newTxError(migration, err)
|
||||
}
|
||||
case Down:
|
||||
_, err := executor.Delete(&MigrationRecord{
|
||||
Id: migration.Id,
|
||||
})
|
||||
if err != nil {
|
||||
if trans, ok := executor.(*gorp.Transaction); ok {
|
||||
_ = trans.Rollback()
|
||||
}
|
||||
|
||||
return applied, newTxError(migration, err)
|
||||
}
|
||||
default:
|
||||
panic("Not possible")
|
||||
}
|
||||
|
||||
if trans, ok := executor.(*gorp.Transaction); ok {
|
||||
if err := trans.Commit(); err != nil {
|
||||
return applied, newTxError(migration, err)
|
||||
}
|
||||
}
|
||||
|
||||
applied++
|
||||
}
|
||||
|
||||
return applied, nil
|
||||
}
|
||||
|
||||
// Plan a migration.
|
||||
func PlanMigration(db *sql.DB, dialect string, m MigrationSource, dir MigrationDirection, max int) ([]*PlannedMigration, *gorp.DbMap, error) {
|
||||
return migSet.PlanMigration(db, dialect, m, dir, max)
|
||||
}
|
||||
|
||||
func (ms MigrationSet) PlanMigration(db *sql.DB, dialect string, m MigrationSource, dir MigrationDirection, max int) ([]*PlannedMigration, *gorp.DbMap, error) {
|
||||
dbMap, err := ms.getMigrationDbMap(db, dialect)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
migrations, err := m.FindMigrations()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var migrationRecords []MigrationRecord
|
||||
_, err = dbMap.Select(&migrationRecords, fmt.Sprintf("SELECT * FROM %s", dbMap.Dialect.QuotedTableForQuery(ms.SchemaName, ms.getTableName())))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// Sort migrations that have been run by Id.
|
||||
var existingMigrations []*Migration
|
||||
for _, migrationRecord := range migrationRecords {
|
||||
existingMigrations = append(existingMigrations, &Migration{
|
||||
Id: migrationRecord.Id,
|
||||
})
|
||||
}
|
||||
sort.Sort(byId(existingMigrations))
|
||||
|
||||
// Make sure all migrations in the database are among the found migrations which
|
||||
// are to be applied.
|
||||
if !ms.IgnoreUnknown {
|
||||
migrationsSearch := make(map[string]struct{})
|
||||
for _, migration := range migrations {
|
||||
migrationsSearch[migration.Id] = struct{}{}
|
||||
}
|
||||
for _, existingMigration := range existingMigrations {
|
||||
if _, ok := migrationsSearch[existingMigration.Id]; !ok {
|
||||
return nil, nil, newPlanError(existingMigration, "unknown migration in database")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get last migration that was run
|
||||
record := &Migration{}
|
||||
if len(existingMigrations) > 0 {
|
||||
record = existingMigrations[len(existingMigrations)-1]
|
||||
}
|
||||
|
||||
result := make([]*PlannedMigration, 0)
|
||||
|
||||
// Add missing migrations up to the last run migration.
|
||||
// This can happen for example when merges happened.
|
||||
if len(existingMigrations) > 0 {
|
||||
result = append(result, ToCatchup(migrations, existingMigrations, record)...)
|
||||
}
|
||||
|
||||
// Figure out which migrations to apply
|
||||
toApply := ToApply(migrations, record.Id, dir)
|
||||
toApplyCount := len(toApply)
|
||||
if max > 0 && max < toApplyCount {
|
||||
toApplyCount = max
|
||||
}
|
||||
for _, v := range toApply[0:toApplyCount] {
|
||||
|
||||
if dir == Up {
|
||||
result = append(result, &PlannedMigration{
|
||||
Migration: v,
|
||||
Queries: v.Up,
|
||||
DisableTransaction: v.DisableTransactionUp,
|
||||
})
|
||||
} else if dir == Down {
|
||||
result = append(result, &PlannedMigration{
|
||||
Migration: v,
|
||||
Queries: v.Down,
|
||||
DisableTransaction: v.DisableTransactionDown,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return result, dbMap, nil
|
||||
}
|
||||
|
||||
// Skip a set of migrations
|
||||
//
|
||||
// Will skip at most `max` migrations. Pass 0 for no limit.
|
||||
//
|
||||
// Returns the number of skipped migrations.
|
||||
func SkipMax(db *sql.DB, dialect string, m MigrationSource, dir MigrationDirection, max int) (int, error) {
|
||||
migrations, dbMap, err := PlanMigration(db, dialect, m, dir, max)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Skip migrations
|
||||
applied := 0
|
||||
for _, migration := range migrations {
|
||||
var executor SqlExecutor
|
||||
|
||||
if migration.DisableTransaction {
|
||||
executor = dbMap
|
||||
} else {
|
||||
executor, err = dbMap.Begin()
|
||||
if err != nil {
|
||||
return applied, newTxError(migration, err)
|
||||
}
|
||||
}
|
||||
|
||||
err = executor.Insert(&MigrationRecord{
|
||||
Id: migration.Id,
|
||||
AppliedAt: time.Now(),
|
||||
})
|
||||
if err != nil {
|
||||
if trans, ok := executor.(*gorp.Transaction); ok {
|
||||
_ = trans.Rollback()
|
||||
}
|
||||
|
||||
return applied, newTxError(migration, err)
|
||||
}
|
||||
|
||||
if trans, ok := executor.(*gorp.Transaction); ok {
|
||||
if err := trans.Commit(); err != nil {
|
||||
return applied, newTxError(migration, err)
|
||||
}
|
||||
}
|
||||
|
||||
applied++
|
||||
}
|
||||
|
||||
return applied, nil
|
||||
}
|
||||
|
||||
// Filter a slice of migrations into ones that should be applied.
|
||||
func ToApply(migrations []*Migration, current string, direction MigrationDirection) []*Migration {
|
||||
var index = -1
|
||||
if current != "" {
|
||||
for index < len(migrations)-1 {
|
||||
index++
|
||||
if migrations[index].Id == current {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if direction == Up {
|
||||
return migrations[index+1:]
|
||||
} else if direction == Down {
|
||||
if index == -1 {
|
||||
return []*Migration{}
|
||||
}
|
||||
|
||||
// Add in reverse order
|
||||
toApply := make([]*Migration, index+1)
|
||||
for i := 0; i < index+1; i++ {
|
||||
toApply[index-i] = migrations[i]
|
||||
}
|
||||
return toApply
|
||||
}
|
||||
|
||||
panic("Not possible")
|
||||
}
|
||||
|
||||
func ToCatchup(migrations, existingMigrations []*Migration, lastRun *Migration) []*PlannedMigration {
|
||||
missing := make([]*PlannedMigration, 0)
|
||||
for _, migration := range migrations {
|
||||
found := false
|
||||
for _, existing := range existingMigrations {
|
||||
if existing.Id == migration.Id {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found && migration.Less(lastRun) {
|
||||
missing = append(missing, &PlannedMigration{
|
||||
Migration: migration,
|
||||
Queries: migration.Up,
|
||||
DisableTransaction: migration.DisableTransactionUp,
|
||||
})
|
||||
}
|
||||
}
|
||||
return missing
|
||||
}
|
||||
|
||||
func GetMigrationRecords(db *sql.DB, dialect string) ([]*MigrationRecord, error) {
|
||||
return migSet.GetMigrationRecords(db, dialect)
|
||||
}
|
||||
|
||||
func (ms MigrationSet) GetMigrationRecords(db *sql.DB, dialect string) ([]*MigrationRecord, error) {
|
||||
dbMap, err := ms.getMigrationDbMap(db, dialect)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var records []*MigrationRecord
|
||||
query := fmt.Sprintf("SELECT * FROM %s ORDER BY %s ASC", dbMap.Dialect.QuotedTableForQuery(ms.SchemaName, ms.getTableName()), dbMap.Dialect.QuoteField("id"))
|
||||
_, err = dbMap.Select(&records, query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return records, nil
|
||||
}
|
||||
|
||||
func (ms MigrationSet) getMigrationDbMap(db *sql.DB, dialect string) (*gorp.DbMap, error) {
|
||||
d, ok := MigrationDialects[dialect]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("Unknown dialect: %s", dialect)
|
||||
}
|
||||
|
||||
// When using the mysql driver, make sure that the parseTime option is
|
||||
// configured, otherwise it won't map time columns to time.Time. See
|
||||
// https://github.com/rubenv/sql-migrate/issues/2
|
||||
if dialect == "mysql" {
|
||||
var out *time.Time
|
||||
err := db.QueryRow("SELECT NOW()").Scan(&out)
|
||||
if err != nil {
|
||||
if err.Error() == "sql: Scan error on column index 0: unsupported driver -> Scan pair: []uint8 -> *time.Time" ||
|
||||
err.Error() == "sql: Scan error on column index 0: unsupported Scan, storing driver.Value type []uint8 into type *time.Time" ||
|
||||
err.Error() == "sql: Scan error on column index 0, name \"NOW()\": unsupported Scan, storing driver.Value type []uint8 into type *time.Time" {
|
||||
return nil, errors.New(`Cannot parse dates.
|
||||
|
||||
Make sure that the parseTime option is supplied to your database connection.
|
||||
Check https://github.com/go-sql-driver/mysql#parsetime for more info.`)
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create migration database map
|
||||
dbMap := &gorp.DbMap{Db: db, Dialect: d}
|
||||
table := dbMap.AddTableWithNameAndSchema(MigrationRecord{}, ms.SchemaName, ms.getTableName()).SetKeys(false, "Id")
|
||||
//dbMap.TraceOn("", log.New(os.Stdout, "migrate: ", log.Lmicroseconds))
|
||||
|
||||
if dialect == "oci8" || dialect == "godror" {
|
||||
table.ColMap("Id").SetMaxSize(4000)
|
||||
}
|
||||
|
||||
err := dbMap.CreateTablesIfNotExists()
|
||||
if err != nil {
|
||||
// Oracle database does not support `if not exists`, so use `ORA-00955:` error code
|
||||
// to check if the table exists.
|
||||
if (dialect == "oci8" || dialect == "godror") && strings.Contains(err.Error(), "ORA-00955:") {
|
||||
return dbMap, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return dbMap, nil
|
||||
}
|
||||
|
||||
// TODO: Run migration + record insert in transaction.
|
||||
22
vendor/github.com/rubenv/sql-migrate/sqlparse/LICENSE
generated
vendored
Normal file
22
vendor/github.com/rubenv/sql-migrate/sqlparse/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2014-2017 by Ruben Vermeersch <ruben@rocketeer.be>
|
||||
Copyright (C) 2012-2014 by Liam Staskawicz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
7
vendor/github.com/rubenv/sql-migrate/sqlparse/README.md
generated
vendored
Normal file
7
vendor/github.com/rubenv/sql-migrate/sqlparse/README.md
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# SQL migration parser
|
||||
|
||||
Based on the [goose](https://bitbucket.org/liamstask/goose) migration parser.
|
||||
|
||||
## License
|
||||
|
||||
This library is distributed under the [MIT](LICENSE) license.
|
||||
235
vendor/github.com/rubenv/sql-migrate/sqlparse/sqlparse.go
generated
vendored
Normal file
235
vendor/github.com/rubenv/sql-migrate/sqlparse/sqlparse.go
generated
vendored
Normal file
@@ -0,0 +1,235 @@
|
||||
package sqlparse
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
sqlCmdPrefix = "-- +migrate "
|
||||
optionNoTransaction = "notransaction"
|
||||
)
|
||||
|
||||
type ParsedMigration struct {
|
||||
UpStatements []string
|
||||
DownStatements []string
|
||||
|
||||
DisableTransactionUp bool
|
||||
DisableTransactionDown bool
|
||||
}
|
||||
|
||||
var (
|
||||
// LineSeparator can be used to split migrations by an exact line match. This line
|
||||
// will be removed from the output. If left blank, it is not considered. It is defaulted
|
||||
// to blank so you will have to set it manually.
|
||||
// Use case: in MSSQL, it is convenient to separate commands by GO statements like in
|
||||
// SQL Query Analyzer.
|
||||
LineSeparator = ""
|
||||
)
|
||||
|
||||
func errNoTerminator() error {
|
||||
if len(LineSeparator) == 0 {
|
||||
return errors.New(`ERROR: The last statement must be ended by a semicolon or '-- +migrate StatementEnd' marker.
|
||||
See https://github.com/rubenv/sql-migrate for details.`)
|
||||
}
|
||||
|
||||
return errors.New(fmt.Sprintf(`ERROR: The last statement must be ended by a semicolon, a line whose contents are %q, or '-- +migrate StatementEnd' marker.
|
||||
See https://github.com/rubenv/sql-migrate for details.`, LineSeparator))
|
||||
}
|
||||
|
||||
// Checks the line to see if the line has a statement-ending semicolon
|
||||
// or if the line contains a double-dash comment.
|
||||
func endsWithSemicolon(line string) bool {
|
||||
|
||||
prev := ""
|
||||
scanner := bufio.NewScanner(strings.NewReader(line))
|
||||
scanner.Split(bufio.ScanWords)
|
||||
|
||||
for scanner.Scan() {
|
||||
word := scanner.Text()
|
||||
if strings.HasPrefix(word, "--") {
|
||||
break
|
||||
}
|
||||
prev = word
|
||||
}
|
||||
|
||||
return strings.HasSuffix(prev, ";")
|
||||
}
|
||||
|
||||
type migrationDirection int
|
||||
|
||||
const (
|
||||
directionNone migrationDirection = iota
|
||||
directionUp
|
||||
directionDown
|
||||
)
|
||||
|
||||
type migrateCommand struct {
|
||||
Command string
|
||||
Options []string
|
||||
}
|
||||
|
||||
func (c *migrateCommand) HasOption(opt string) bool {
|
||||
for _, specifiedOption := range c.Options {
|
||||
if specifiedOption == opt {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func parseCommand(line string) (*migrateCommand, error) {
|
||||
cmd := &migrateCommand{}
|
||||
|
||||
if !strings.HasPrefix(line, sqlCmdPrefix) {
|
||||
return nil, errors.New("ERROR: not a sql-migrate command")
|
||||
}
|
||||
|
||||
fields := strings.Fields(line[len(sqlCmdPrefix):])
|
||||
if len(fields) == 0 {
|
||||
return nil, errors.New(`ERROR: incomplete migration command`)
|
||||
}
|
||||
|
||||
cmd.Command = fields[0]
|
||||
|
||||
cmd.Options = fields[1:]
|
||||
|
||||
return cmd, nil
|
||||
}
|
||||
|
||||
// Split the given sql script into individual statements.
|
||||
//
|
||||
// The base case is to simply split on semicolons, as these
|
||||
// naturally terminate a statement.
|
||||
//
|
||||
// However, more complex cases like pl/pgsql can have semicolons
|
||||
// within a statement. For these cases, we provide the explicit annotations
|
||||
// 'StatementBegin' and 'StatementEnd' to allow the script to
|
||||
// tell us to ignore semicolons.
|
||||
func ParseMigration(r io.ReadSeeker) (*ParsedMigration, error) {
|
||||
p := &ParsedMigration{}
|
||||
|
||||
_, err := r.Seek(0, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
scanner := bufio.NewScanner(r)
|
||||
scanner.Buffer(make([]byte, 0, 64*1024), 1024*1024)
|
||||
|
||||
statementEnded := false
|
||||
ignoreSemicolons := false
|
||||
currentDirection := directionNone
|
||||
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
// ignore comment except beginning with '-- +'
|
||||
if strings.HasPrefix(line, "-- ") && !strings.HasPrefix(line, "-- +") {
|
||||
continue
|
||||
}
|
||||
|
||||
// handle any migrate-specific commands
|
||||
if strings.HasPrefix(line, sqlCmdPrefix) {
|
||||
cmd, err := parseCommand(line)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
switch cmd.Command {
|
||||
case "Up":
|
||||
if len(strings.TrimSpace(buf.String())) > 0 {
|
||||
return nil, errNoTerminator()
|
||||
}
|
||||
currentDirection = directionUp
|
||||
if cmd.HasOption(optionNoTransaction) {
|
||||
p.DisableTransactionUp = true
|
||||
}
|
||||
break
|
||||
|
||||
case "Down":
|
||||
if len(strings.TrimSpace(buf.String())) > 0 {
|
||||
return nil, errNoTerminator()
|
||||
}
|
||||
currentDirection = directionDown
|
||||
if cmd.HasOption(optionNoTransaction) {
|
||||
p.DisableTransactionDown = true
|
||||
}
|
||||
break
|
||||
|
||||
case "StatementBegin":
|
||||
if currentDirection != directionNone {
|
||||
ignoreSemicolons = true
|
||||
}
|
||||
break
|
||||
|
||||
case "StatementEnd":
|
||||
if currentDirection != directionNone {
|
||||
statementEnded = (ignoreSemicolons == true)
|
||||
ignoreSemicolons = false
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if currentDirection == directionNone {
|
||||
continue
|
||||
}
|
||||
|
||||
isLineSeparator := !ignoreSemicolons && len(LineSeparator) > 0 && line == LineSeparator
|
||||
|
||||
if !isLineSeparator && !strings.HasPrefix(line, "-- +") {
|
||||
if _, err := buf.WriteString(line + "\n"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// Wrap up the two supported cases: 1) basic with semicolon; 2) psql statement
|
||||
// Lines that end with semicolon that are in a statement block
|
||||
// do not conclude statement.
|
||||
if (!ignoreSemicolons && (endsWithSemicolon(line) || isLineSeparator)) || statementEnded {
|
||||
statementEnded = false
|
||||
switch currentDirection {
|
||||
case directionUp:
|
||||
p.UpStatements = append(p.UpStatements, buf.String())
|
||||
|
||||
case directionDown:
|
||||
p.DownStatements = append(p.DownStatements, buf.String())
|
||||
|
||||
default:
|
||||
panic("impossible state")
|
||||
}
|
||||
|
||||
buf.Reset()
|
||||
}
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// diagnose likely migration script errors
|
||||
if ignoreSemicolons {
|
||||
return nil, errors.New("ERROR: saw '-- +migrate StatementBegin' with no matching '-- +migrate StatementEnd'")
|
||||
}
|
||||
|
||||
if currentDirection == directionNone {
|
||||
return nil, errors.New(`ERROR: no Up/Down annotations found, so no statements were executed.
|
||||
See https://github.com/rubenv/sql-migrate for details.`)
|
||||
}
|
||||
|
||||
// allow comment without sql instruction. Example:
|
||||
// -- +migrate Down
|
||||
// -- nothing to downgrade!
|
||||
if len(strings.TrimSpace(buf.String())) > 0 && !strings.HasPrefix(buf.String(), "-- +") {
|
||||
return nil, errNoTerminator()
|
||||
}
|
||||
|
||||
return p, nil
|
||||
}
|
||||
Reference in New Issue
Block a user