Update dependencies (#5518)
This commit is contained in:
6
vendor/github.com/rubenv/sql-migrate/.dockerignore
generated
vendored
Normal file
6
vendor/github.com/rubenv/sql-migrate/.dockerignore
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
*
|
||||
!go.mod
|
||||
!go.sum
|
||||
!*.go
|
||||
!sql-migrate/*.go
|
||||
!sqlparse/*.go
|
||||
1
vendor/github.com/rubenv/sql-migrate/.gitignore
generated
vendored
1
vendor/github.com/rubenv/sql-migrate/.gitignore
generated
vendored
@@ -1,6 +1,7 @@
|
||||
.*.swp
|
||||
*.test
|
||||
.idea
|
||||
/vendor/
|
||||
|
||||
/sql-migrate/test.db
|
||||
/test.db
|
||||
|
||||
2
vendor/github.com/rubenv/sql-migrate/.travis.yml
generated
vendored
2
vendor/github.com/rubenv/sql-migrate/.travis.yml
generated
vendored
@@ -5,6 +5,8 @@ sudo: false
|
||||
go:
|
||||
- "1.13"
|
||||
- "1.14"
|
||||
- "1.15"
|
||||
- "1.16"
|
||||
|
||||
services:
|
||||
- mysql
|
||||
|
||||
25
vendor/github.com/rubenv/sql-migrate/Dockerfile
generated
vendored
Normal file
25
vendor/github.com/rubenv/sql-migrate/Dockerfile
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
ARG GO_VERSION=1.16.2
|
||||
ARG ALPINE_VERSION=3.12
|
||||
|
||||
### Vendor
|
||||
FROM golang:${GO_VERSION} as vendor
|
||||
COPY . /project
|
||||
WORKDIR /project
|
||||
RUN go mod tidy && go mod vendor
|
||||
|
||||
### Build binary
|
||||
FROM golang:${GO_VERSION} as build-binary
|
||||
COPY . /project
|
||||
COPY --from=vendor /project/vendor /project/vendor
|
||||
WORKDIR /project
|
||||
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 GO111MODULE=on go build \
|
||||
-v \
|
||||
-mod vendor \
|
||||
-o /project/bin/sql-migrate \
|
||||
/project/sql-migrate
|
||||
|
||||
### Image
|
||||
FROM alpine:${ALPINE_VERSION} as image
|
||||
COPY --from=build-binary /project/bin/sql-migrate /usr/local/bin/sql-migrate
|
||||
RUN chmod +x /usr/local/bin/sql-migrate
|
||||
ENTRYPOINT ["sql-migrate"]
|
||||
2
vendor/github.com/rubenv/sql-migrate/LICENSE
generated
vendored
2
vendor/github.com/rubenv/sql-migrate/LICENSE
generated
vendored
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2014-2019 by Ruben Vermeersch <ruben@rocketeer.be>
|
||||
Copyright (C) 2014-2021 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
|
||||
|
||||
8
vendor/github.com/rubenv/sql-migrate/README.md
generated
vendored
8
vendor/github.com/rubenv/sql-migrate/README.md
generated
vendored
@@ -1,6 +1,6 @@
|
||||
# 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).
|
||||
> SQL Schema migration tool for [Go](https://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)
|
||||
|
||||
@@ -15,7 +15,7 @@ Using [modl](https://github.com/jmoiron/modl)? Check out [modl-migrate](https://
|
||||
* 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/)
|
||||
* Works great with other libraries such as [sqlx](https://jmoiron.github.io/sqlx/)
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -298,7 +298,7 @@ Normally each migration is run within a transaction in order to guarantee that i
|
||||
|
||||
```sql
|
||||
-- +migrate Up notransaction
|
||||
CREATE UNIQUE INDEX people_unique_id_idx CONCURRENTLY ON people (id);
|
||||
CREATE UNIQUE INDEX CONCURRENTLY people_unique_id_idx ON people (id);
|
||||
|
||||
-- +migrate Down
|
||||
DROP INDEX people_unique_id_idx;
|
||||
@@ -383,7 +383,7 @@ type MigrationSource interface {
|
||||
|
||||
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/)
|
||||
## Usage with [sqlx](https://jmoiron.github.io/sqlx/)
|
||||
|
||||
This library is compatible with sqlx. When calling migrate just dereference the DB from your `*sqlx.DB`:
|
||||
|
||||
|
||||
27
vendor/github.com/rubenv/sql-migrate/migrate.go
generated
vendored
27
vendor/github.com/rubenv/sql-migrate/migrate.go
generated
vendored
@@ -15,8 +15,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-gorp/gorp/v3"
|
||||
"github.com/rubenv/sql-migrate/sqlparse"
|
||||
"gopkg.in/gorp.v1"
|
||||
)
|
||||
|
||||
type MigrationDirection int
|
||||
@@ -37,6 +37,8 @@ type MigrationSet struct {
|
||||
//
|
||||
// This should be used sparingly as it is removing a safety check.
|
||||
IgnoreUnknown bool
|
||||
// DisableCreateTable disable the creation of the migration table
|
||||
DisableCreateTable bool
|
||||
}
|
||||
|
||||
var migSet = MigrationSet{}
|
||||
@@ -106,6 +108,11 @@ func SetSchema(name string) {
|
||||
}
|
||||
}
|
||||
|
||||
// SetDisableCreateTable sets the boolean to disable the creation of the migration table
|
||||
func SetDisableCreateTable(disable bool) {
|
||||
migSet.DisableCreateTable = disable
|
||||
}
|
||||
|
||||
// SetIgnoreUnknown sets the flag that skips database check to see if there is a
|
||||
// migration in the database that is not in migration source.
|
||||
//
|
||||
@@ -229,7 +236,7 @@ type HttpFileSystemMigrationSource struct {
|
||||
var _ MigrationSource = (*HttpFileSystemMigrationSource)(nil)
|
||||
|
||||
func (f HttpFileSystemMigrationSource) FindMigrations() ([]*Migration, error) {
|
||||
return findMigrations(f.FileSystem)
|
||||
return findMigrations(f.FileSystem, "/")
|
||||
}
|
||||
|
||||
// A set of migrations loaded from a directory.
|
||||
@@ -241,13 +248,13 @@ var _ MigrationSource = (*FileMigrationSource)(nil)
|
||||
|
||||
func (f FileMigrationSource) FindMigrations() ([]*Migration, error) {
|
||||
filesystem := http.Dir(f.Dir)
|
||||
return findMigrations(filesystem)
|
||||
return findMigrations(filesystem, "/")
|
||||
}
|
||||
|
||||
func findMigrations(dir http.FileSystem) ([]*Migration, error) {
|
||||
func findMigrations(dir http.FileSystem, root string) ([]*Migration, error) {
|
||||
migrations := make([]*Migration, 0)
|
||||
|
||||
file, err := dir.Open("/")
|
||||
file, err := dir.Open(root)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -259,7 +266,7 @@ func findMigrations(dir http.FileSystem) ([]*Migration, error) {
|
||||
|
||||
for _, info := range files {
|
||||
if strings.HasSuffix(info.Name(), ".sql") {
|
||||
migration, err := migrationFromFile(dir, info)
|
||||
migration, err := migrationFromFile(dir, root, info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -274,8 +281,8 @@ func findMigrations(dir http.FileSystem) ([]*Migration, error) {
|
||||
return migrations, nil
|
||||
}
|
||||
|
||||
func migrationFromFile(dir http.FileSystem, info os.FileInfo) (*Migration, error) {
|
||||
path := fmt.Sprintf("/%s", strings.TrimPrefix(info.Name(), "/"))
|
||||
func migrationFromFile(dir http.FileSystem, root string, info os.FileInfo) (*Migration, error) {
|
||||
path := path.Join(root, info.Name())
|
||||
file, err := dir.Open(path)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error while opening %s: %s", info.Name(), err)
|
||||
@@ -752,6 +759,10 @@ Check https://github.com/go-sql-driver/mysql#parsetime for more info.`)
|
||||
table.ColMap("Id").SetMaxSize(4000)
|
||||
}
|
||||
|
||||
if migSet.DisableCreateTable {
|
||||
return dbMap, nil
|
||||
}
|
||||
|
||||
err := dbMap.CreateTablesIfNotExists()
|
||||
if err != nil {
|
||||
// Oracle database does not support `if not exists`, so use `ORA-00955:` error code
|
||||
|
||||
23
vendor/github.com/rubenv/sql-migrate/migrate_go116.go
generated
vendored
Normal file
23
vendor/github.com/rubenv/sql-migrate/migrate_go116.go
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
//go:build go1.16
|
||||
// +build go1.16
|
||||
|
||||
package migrate
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// A set of migrations loaded from an go1.16 embed.FS
|
||||
|
||||
type EmbedFileSystemMigrationSource struct {
|
||||
FileSystem embed.FS
|
||||
|
||||
Root string
|
||||
}
|
||||
|
||||
var _ MigrationSource = (*EmbedFileSystemMigrationSource)(nil)
|
||||
|
||||
func (f EmbedFileSystemMigrationSource) FindMigrations() ([]*Migration, error) {
|
||||
return findMigrations(http.FS(f.FileSystem), f.Root)
|
||||
}
|
||||
8
vendor/github.com/rubenv/sql-migrate/test-migrations/1_initial.sql
generated
vendored
Normal file
8
vendor/github.com/rubenv/sql-migrate/test-migrations/1_initial.sql
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
-- +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;
|
||||
5
vendor/github.com/rubenv/sql-migrate/test-migrations/2_record.sql
generated
vendored
Normal file
5
vendor/github.com/rubenv/sql-migrate/test-migrations/2_record.sql
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
-- +migrate Up
|
||||
INSERT INTO people (id) VALUES (1);
|
||||
|
||||
-- +migrate Down
|
||||
DELETE FROM people WHERE id=1;
|
||||
Reference in New Issue
Block a user