Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
e2e: add clickhouse and update v2 (pressly#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfridman authored Jun 20, 2022
1 parent e8d93a0 commit 1b45f37
Show file tree
Hide file tree
Showing 17 changed files with 850 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

strategy:
matrix:
go-version: [1.16, 1.17, 1.18]
go-version: [1.17, 1.18]
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,16 @@ jobs:
- name: Run e2e ${{ matrix.dialect }} tests
run: |
make test-e2e-${{ matrix.dialect }}
test-clickhouse:
name: Run clickhouse tests
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: "1.18"
- name: Run clickhouse test
run: make test-clickhouse
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ test-e2e-postgres:
test-e2e-mysql:
go test -v ./tests/e2e -dialect=mysql

test-clickhouse:
go test -timeout=10m -count=1 -race -v ./tests/clickhouse -test.short

docker-cleanup:
docker stop -t=0 $$(docker ps --filter="label=goose_test" -aq)
2 changes: 1 addition & 1 deletion cmd/goose/driver_clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
package main

import (
_ "github.com/ClickHouse/clickhouse-go"
_ "github.com/ClickHouse/clickhouse-go/v2"
)
8 changes: 6 additions & 2 deletions dialect.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func (m TiDBDialect) deleteVersionSQL() string {
type ClickHouseDialect struct{}

func (m ClickHouseDialect) createVersionTableSQL() string {
return fmt.Sprintf(`CREATE TABLE %s (
return fmt.Sprintf(`CREATE TABLE IF NOT EXISTS %s (
version_id Int64,
is_applied UInt8,
date Date default now(),
Expand All @@ -310,7 +310,11 @@ func (m ClickHouseDialect) dbVersionQuery(db *sql.DB) (*sql.Rows, error) {
}

func (m ClickHouseDialect) insertVersionSQL() string {
return fmt.Sprintf("INSERT INTO %s (version_id, is_applied) VALUES ($1, $2)", TableName())
// Note, the second argument is_applied is hard-coded to 1 (true). This is to account for
// the /v2 ClickHouse driver not converting bool to uint8. This will hopefully be resolved
// upstream: https://github.com/ClickHouse/clickhouse-go/issues/621
// Throughout the codebase this value is always true, hence it has no effect.
return fmt.Sprintf("INSERT INTO %s (version_id, is_applied) VALUES ($1, 1)", TableName())
}

func (m ClickHouseDialect) migrationSQL() string {
Expand Down
56 changes: 54 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module github.com/pressly/goose/v3

go 1.16
go 1.17

require (
github.com/ClickHouse/clickhouse-go v1.5.4
github.com/ClickHouse/clickhouse-go/v2 v2.1.0
github.com/avast/retry-go/v4 v4.1.0
github.com/denisenkom/go-mssqldb v0.12.2
github.com/go-sql-driver/mysql v1.6.0
github.com/lib/pq v1.10.6
Expand All @@ -12,3 +13,54 @@ require (
github.com/ziutek/mymysql v1.5.4
modernc.org/sqlite v1.17.3
)

require (
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/containerd/continuity v0.3.0 // indirect
github.com/docker/cli v20.10.14+incompatible // indirect
github.com/docker/docker v20.10.7+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect
github.com/golang-sql/sqlexp v0.1.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/opencontainers/runc v1.1.2 // indirect
github.com/paulmach/orb v0.7.1 // indirect
github.com/pierrec/lz4/v4 v4.1.15 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
go.opentelemetry.io/otel v1.7.0 // indirect
go.opentelemetry.io/otel/trace v1.7.0 // indirect
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 // indirect
golang.org/x/mod v0.4.2 // indirect
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d // indirect
golang.org/x/sys v0.0.0-20220429233432-b5fbb4746d32 // indirect
golang.org/x/tools v0.1.7 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
lukechampine.com/uint128 v1.1.1 // indirect
modernc.org/cc/v3 v3.36.0 // indirect
modernc.org/ccgo/v3 v3.16.6 // indirect
modernc.org/libc v1.16.7 // indirect
modernc.org/mathutil v1.4.1 // indirect
modernc.org/memory v1.1.1 // indirect
modernc.org/opt v0.1.1 // indirect
modernc.org/strutil v1.1.1 // indirect
modernc.org/token v1.0.0 // indirect
)
Loading

0 comments on commit 1b45f37

Please sign in to comment.