Skip to content

Commit

Permalink
resolved upstream conflicts in go.*
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-garcia committed Dec 8, 2023
2 parents c441785 + 856ea12 commit d6166ab
Show file tree
Hide file tree
Showing 76 changed files with 2,618 additions and 673 deletions.
29 changes: 20 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,27 @@ on:

jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-go@v3
with:
go-version: "1.20.x"
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
version: latest

test:
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.17.x", "1.18.x"]
go: ["1.19.x", "1.20.x"]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-go@v2
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}

Expand Down Expand Up @@ -55,15 +60,15 @@ jobs:
# 3. When the workflow is triggered by a tag with `v` prefix
if: ${{ success() && github.repository == 'golang-migrate/migrate' && startsWith(github.ref, 'refs/tags/v') }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- uses: actions/setup-go@v2
- uses: actions/setup-go@v3
with:
go-version: "1.18.x"
go-version: "1.19.x"

- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
Expand All @@ -89,9 +94,15 @@ jobs:
- run: package_cloud push golang-migrate/migrate/ubuntu/focal dist/migrate.linux-amd64.deb
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
- run: package_cloud push golang-migrate/migrate/ubuntu/jammy dist/migrate.linux-amd64.deb
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
- run: package_cloud push golang-migrate/migrate/debian/buster dist/migrate.linux-amd64.deb
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
- run: package_cloud push golang-migrate/migrate/debian/bullseye dist/migrate.linux-amd64.deb
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
- run: package_cloud push golang-migrate/migrate/debian/bookworm dist/migrate.linux-amd64.deb
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ release:
prerelease: auto
source:
enabled: true
rlcp: true
format: zip
changelog:
skip: false
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.github-actions
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ RUN ln -s /usr/local/bin/migrate /usr/bin/migrate
RUN ln -s /usr/local/bin/migrate /migrate

ENTRYPOINT ["migrate"]
CMD ["--help"]
CMD ["--help"]
6 changes: 3 additions & 3 deletions GETTING_STARTED.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Getting started
Before you start, you should understand the concept of forward/up and reverse/down database migrations.

Configure a database for your application. Make sure that your database driver is supported [here](README.md#databases)
Configure a database for your application. Make sure that your database driver is supported [here](README.md#databases).

## Create migrations
Create some migrations using migrate CLI. Here is an example:
Expand All @@ -10,7 +10,7 @@ migrate create -ext sql -dir db/migrations -seq create_users_table
```
Once you create your files, you should fill them.

**IMPORTANT:** In a project developed by more than one person there is a chance of migrations inconsistency - e.g. two developers can create conflicting migrations, and the developer that created his migration later gets it merged to the repository first.
**IMPORTANT:** In a project developed by more than one person there is a chance of migrations inconsistency - e.g. two developers can create conflicting migrations, and the developer that created their migration later gets it merged to the repository first.
Developers and Teams should keep an eye on such cases (especially during code review).
[Here](https://github.com/golang-migrate/migrate/issues/179#issuecomment-475821264) is the issue summary if you would like to read more.

Expand All @@ -30,7 +30,7 @@ Just add the code to your app and you're ready to go!

Before commiting your migrations you should run your migrations up, down, and then up again to see if migrations are working properly both ways.
(e.g. if you created a table in a migration but reverse migration did not delete it, you will encounter an error when running the forward migration again)
It's also worth checking your migrations in a separate, containerized environment. You can find some tools in the end of this document.
It's also worth checking your migrations in a separate, containerized environment. You can find some tools at the [end of this document](#further-reading).

**IMPORTANT:** If you would like to run multiple instances of your app on different machines be sure to use a database that supports locking when running migrations. Otherwise you may encounter issues.

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SOURCE ?= file go_bindata github github_ee bitbucket aws_s3 google_cloud_storage godoc_vfs gitlab
DATABASE ?= postgres mysql redshift cassandra spanner cockroachdb clickhouse mongodb sqlserver firebird neo4j pgx
DATABASE ?= postgres mysql redshift cassandra spanner cockroachdb yugabytedb clickhouse mongodb sqlserver firebird neo4j pgx pgx5
DATABASE_TEST ?= $(DATABASE) sqlite sqlite3 sqlcipher
BUILD_NUMBER ?= 0
VERSION ?= $(shell git describe --tags --long --dirty=-unsupported 2>/dev/null | cut -c 2-)-j$(BUILD_NUMBER)
Expand Down
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/golang-migrate/migrate/CI/master)](https://github.com/golang-migrate/migrate/actions/workflows/ci.yaml?query=branch%3Amaster)
[![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/golang-migrate/migrate/ci.yaml?branch=master)](https://github.com/golang-migrate/migrate/actions/workflows/ci.yaml?query=branch%3Amaster)
[![GoDoc](https://pkg.go.dev/badge/github.com/golang-migrate/migrate)](https://pkg.go.dev/github.com/golang-migrate/migrate/v4)
[![Coverage Status](https://img.shields.io/coveralls/github/golang-migrate/migrate/master.svg)](https://coveralls.io/github/golang-migrate/migrate?branch=master)
[![packagecloud.io](https://img.shields.io/badge/deb-packagecloud.io-844fec.svg)](https://packagecloud.io/golang-migrate/migrate?filter=debs)
[![Docker Pulls](https://img.shields.io/docker/pulls/migrate/migrate.svg)](https://hub.docker.com/r/migrate/migrate/)
![Supported Go Versions](https://img.shields.io/badge/Go-1.17%2C%201.18-lightgrey.svg)
![Supported Go Versions](https://img.shields.io/badge/Go-1.19%2C%201.20-lightgrey.svg)
[![GitHub Release](https://img.shields.io/github/release/golang-migrate/migrate.svg)](https://github.com/golang-migrate/migrate/releases)
[![Go Report Card](https://goreportcard.com/badge/github.com/golang-migrate/migrate)](https://goreportcard.com/report/github.com/golang-migrate/migrate)
[![Go Report Card](https://goreportcard.com/badge/github.com/golang-migrate/migrate/v4)](https://goreportcard.com/report/github.com/golang-migrate/migrate/v4)

# migrate

Expand All @@ -24,7 +24,8 @@ Forked from [mattes/migrate](https://github.com/mattes/migrate)
Database drivers run migrations. [Add a new database?](database/driver.go)

* [PostgreSQL](database/postgres)
* [PGX](database/pgx)
* [PGX v4](database/pgx)
* [PGX v5](database/pgx/v5)
* [Redshift](database/redshift)
* [Ql](database/ql)
* [Cassandra](database/cassandra)
Expand All @@ -38,6 +39,7 @@ Database drivers run migrations. [Add a new database?](database/driver.go)
* [Shell](database/shell) ([todo #171](https://github.com/mattes/migrate/issues/171))
* [Google Cloud Spanner](database/spanner)
* [CockroachDB](database/cockroachdb)
* [YugabyteDB](database/yugabytedb)
* [ClickHouse](database/clickhouse)
* [Firebird](database/firebird)
* [MS SQL Server](database/sqlserver)
Expand Down Expand Up @@ -108,7 +110,7 @@ $ docker run -v {{ migration dir }}:/migrations --network host migrate/migrate
* Uses `io.Reader` streams internally for low memory overhead.
* Thread-safe and no goroutine leaks.

__[Go Documentation](https://godoc.org/github.com/golang-migrate/migrate)__
__[Go Documentation](https://pkg.go.dev/github.com/golang-migrate/migrate/v4)__

```go
import (
Expand Down Expand Up @@ -168,6 +170,11 @@ Each migration has an up and down migration. [Why?](FAQ.md#why-two-separate-file

[Best practices: How to write migrations.](MIGRATIONS.md)

## Coming from another db migration tool?

Check out [migradaptor](https://github.com/musinit/migradaptor/).
*Note: migradaptor is not affliated or supported by this project*

## Versions

Version | Supported? | Import | Notes
Expand Down
16 changes: 16 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Security Policy

## Supported Versions

| Version | Supported |
| ------- | ------------------ |
| master | :white_check_mark: |
| 4.x | :white_check_mark: |
| 3.x | :x: |
| < 3.0 | :x: |

## Reporting a Vulnerability

We prefer [coordinated disclosures](https://en.wikipedia.org/wiki/Coordinated_vulnerability_disclosure). To start one, create a GitHub security advisory following [these instructions](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability)

Please suggest potential impact and urgency in your reports.
6 changes: 3 additions & 3 deletions cmd/migrate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[Release Downloads](https://github.com/golang-migrate/migrate/releases)

```bash
$ curl -L https://github.com/golang-migrate/migrate/releases/download/$version/migrate.$platform-amd64.tar.gz | tar xvz
$ curl -L https://github.com/golang-migrate/migrate/releases/download/$version/migrate.$os-$arch.tar.gz | tar xvz
```

### MacOS
Expand Down Expand Up @@ -63,7 +63,7 @@ $ go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@l
to build the cli for use with other databases, replace the `postgres` build tag
with the appropriate database tag(s) for the databases desired. The tags
correspond to the names of the sub-packages underneath the
[`database`](../database) package.
[`database`](../../database) package.
1. Similarly to the database build tags, if you need to support other sources, use the appropriate build tag(s).
1. Support for build constraints will be removed in the future: https://github.com/golang-migrate/migrate/issues/60
1. For versions of Go 1.15 and lower, [make sure](https://github.com/golang-migrate/migrate/pull/257#issuecomment-705249902) you're not installing the `migrate` CLI from a module. e.g. there should not be any `go.mod` files in your current directory or any directory from your current directory to the root
Expand Down Expand Up @@ -127,7 +127,7 @@ $ migrate -database "$MY_MIGRATE_DATABASE"
Check out https://stedolan.github.io/jq/

```bash
$ migrate -database "$(cat config.json | jq '.database')"
$ migrate -database "$(cat config.json | jq -r '.database')"
```

### YAML files
Expand Down
6 changes: 3 additions & 3 deletions database/cassandra/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package cassandra
import (
"errors"
"fmt"
"go.uber.org/atomic"
"io"
"io/ioutil"
nurl "net/url"
"strconv"
"strings"
"time"

"go.uber.org/atomic"

"github.com/gocql/gocql"
"github.com/golang-migrate/migrate/v4/database"
"github.com/golang-migrate/migrate/v4/database/multistmt"
Expand Down Expand Up @@ -231,7 +231,7 @@ func (c *Cassandra) Run(migration io.Reader) error {
return err
}

migr, err := ioutil.ReadAll(migration)
migr, err := io.ReadAll(migration)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion database/clickhouse/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ClickHouse

`clickhouse://username:password@host:port/database=clicks?x-multi-statement=true`
`clickhouse://host:port?username=user&password=password&database=clicks&x-multi-statement=true`

| URL Query | Description |
|------------|-------------|
Expand Down
3 changes: 1 addition & 2 deletions database/clickhouse/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"database/sql"
"fmt"
"io"
"io/ioutil"
"net/url"
"strconv"
"strings"
Expand Down Expand Up @@ -153,7 +152,7 @@ func (ch *ClickHouse) Run(r io.Reader) error {
return err
}

migration, err := ioutil.ReadAll(r)
migration, err := io.ReadAll(r)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions database/cockroachdb/TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ And in the `.down.sql` let's delete it:
```
DROP TABLE IF EXISTS example.users;
```
By adding `IF EXISTS/IF NOT EXISTS` we are making migrations idempotent - you can read more about idempotency in [getting started](GETTING_STARTED.md#create-migrations)
By adding `IF EXISTS/IF NOT EXISTS` we are making migrations idempotent - you can read more about idempotency in [getting started](/GETTING_STARTED.md#create-migrations)

## Run migrations
```
Expand Down Expand Up @@ -139,4 +139,4 @@ func main() {
}
}
```
You can find details [here](README.md#use-in-your-go-project)
You can find details [here](README.md#use-in-your-go-project)
14 changes: 4 additions & 10 deletions database/cockroachdb/cockroachdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,17 @@ import (
"context"
"database/sql"
"fmt"
"go.uber.org/atomic"
"io"
"io/ioutil"
nurl "net/url"
"regexp"
"strconv"
)

import (
"github.com/cockroachdb/cockroach-go/v2/crdb"
"github.com/hashicorp/go-multierror"
"github.com/lib/pq"
)

import (
"github.com/golang-migrate/migrate/v4"
"github.com/golang-migrate/migrate/v4/database"
"github.com/hashicorp/go-multierror"
"github.com/lib/pq"
"go.uber.org/atomic"
)

func init() {
Expand Down Expand Up @@ -217,7 +211,7 @@ func (c *CockroachDb) Unlock() error {
}

func (c *CockroachDb) Run(migration io.Reader) error {
migr, err := ioutil.ReadAll(migration)
migr, err := io.ReadAll(migration)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion database/driver.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package database provides the Database interface.
// Package database provides the Driver interface.
// All database drivers must implement this interface, register themselves,
// optionally provide a `WithInstance` function and pass the tests
// in package database/testing.
Expand Down
8 changes: 4 additions & 4 deletions database/firebird/firebird.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
"context"
"database/sql"
"fmt"
"io"
nurl "net/url"

"github.com/golang-migrate/migrate/v4"
"github.com/golang-migrate/migrate/v4/database"
"github.com/hashicorp/go-multierror"
_ "github.com/nakagami/firebirdsql"
"go.uber.org/atomic"
"io"
"io/ioutil"
nurl "net/url"
)

func init() {
Expand Down Expand Up @@ -122,7 +122,7 @@ func (f *Firebird) Unlock() error {
}

func (f *Firebird) Run(migration io.Reader) error {
migr, err := ioutil.ReadAll(migration)
migr, err := io.ReadAll(migration)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit d6166ab

Please sign in to comment.