Skip to content

Commit

Permalink
25 mysql driver supported (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
raoptimus authored Nov 19, 2021
1 parent b8b1a50 commit 6272d49
Show file tree
Hide file tree
Showing 49 changed files with 7,458 additions and 53 deletions.
8 changes: 7 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ POSTGRES_MIGRATIONS_PATH=./db/postgresMigration/test_migrates

CLICKHOUSE_DSN=clickhouse://default:@clickhouse:9000/docker?sslmode=disable&compress=true&debug=false
CLICKHOUSE_MIGRATIONS_PATH=./db/clickhouseMigration/test_migrates

CLICKHOUSE_CLUSTER_DSN1=clickhouse://default:@clickhouse1:9000/docker?sslmode=disable&compress=true&debug=false
CLICKHOUSE_CLUSTER_DSN2=clickhouse://default:@clickhouse2:9000/docker?sslmode=disable&compress=true&debug=false
CLICKHOUSE_CLUSTER_NAME=test_cluster
CLICKHOUSE_CLUSTER_MIGRATIONS_PATH=./db/clickhouseMigration/test_cluster_migrates

MYSQL_DSN=mysql://docker:docker@tcp(mysql:3306)/docker
MYSQL_ROOT_PASSWORD=docker-pw
MYSQL_PASSWORD=docker
MYSQL_USER=docker
MYSQL_DATABASE=docker
MYSQL_MIGRATIONS_PATH=./db/mysqlMigration/test_migrates
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Test

on:
push:

jobs:
docker:
timeout-minutes: 10
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Cache go mods
uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Pull containers
run: docker-compose -f "docker-compose.yml" pull

- name: Cache containers
uses: satackey/[email protected]
continue-on-error: true

- name: Start containers
run: docker-compose -f "docker-compose.yml" up -d --build

- name: Sleep for 5 seconds
uses: jakejarvis/wait-action@master
with:
time: '5s'

- name: Run ps
run: docker-compose -f "docker-compose.yml" ps

- name: Run logs
run: docker-compose -f "docker-compose.yml" logs

- name: Run tests
run: docker-compose -f "docker-compose.yml" exec -T app make test

- name: Stop containers
if: always()
run: docker-compose -f "docker-compose.yml" down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
.build
.coverage
build.sh
48 changes: 0 additions & 48 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Database Migration tool in CLI on Golang that allows you to keep track of databa
The db migration tool currently supports the following db drivers:
- clickhouse
- postgres
- mysql

### Creating Migrations
To create a new migration, run the following command:
Expand Down
17 changes: 13 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.7"

services:
clickhouse:
image: yandex/clickhouse-server:20.9.2.20
image: yandex/clickhouse-server:21.11.3.6-alpine
volumes:
- "./docker/volume/clickhouse/dump:/docker-entrypoint-initdb.d/"

Expand All @@ -13,6 +13,11 @@ services:
env_file:
- .env

mysql:
image: mysql:8.0.27
env_file:
- .env

app:
image: raoptimus/go-magick:latest
working_dir: "/usr/src/app"
Expand All @@ -22,16 +27,20 @@ services:
- clickhouse1
- clickhouse2
- postgres
- mysql
volumes:
- "./:/usr/src/app"
- "~/.cache/go-build:/root/.cache/go-build"
- "~/go/pkg/mod:/go/pkg/mod"
env_file:
- .env

zookeeper:
image: zookeeper

clickhouse1:
image: yandex/clickhouse-server:20.9.2.20
image: yandex/clickhouse-server:21.11.3.6-alpine
restart: on-failure
volumes:
- "./docker/volume/clickhouse-cluster/dump:/docker-entrypoint-initdb.d/"
- "./docker/volume/clickhouse-cluster/config/config_1.xml:/etc/clickhouse-server/config.xml"
Expand All @@ -40,9 +49,9 @@ services:
- zookeeper

clickhouse2:
image: yandex/clickhouse-server:20.9.2.20
image: yandex/clickhouse-server:21.11.3.6-alpine
restart: on-failure
volumes:
- "./docker/volume/clickhouse-cluster/dump:/docker-entrypoint-initdb.d/"
- "./docker/volume/clickhouse-cluster/config/config_2.xml:/etc/clickhouse-server/config.xml"
- "./docker/volume/clickhouse-cluster/config/config_replica.xml:/etc/clickhouse-server/clickhouse_replication_config.xml"
depends_on:
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ go 1.15

require (
github.com/ClickHouse/clickhouse-go v1.4.3
github.com/go-sql-driver/mysql v1.4.0
github.com/lib/pq v1.0.0
github.com/stretchr/testify v1.6.1
github.com/urfave/cli/v2 v2.2.0
google.golang.org/appengine v1.6.7 // indirect
)
9 changes: 9 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSY
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-sql-driver/mysql v1.4.0 h1:7LxgVwFb2hIQtMm87NdgAVfXjnt4OePseqT1tKx+opk=
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=
github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
Expand All @@ -28,6 +30,13 @@ github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/urfave/cli/v2 v2.2.0 h1:JTTnM6wKzdA0Jqodd966MVj4vWbbquZykeX1sKbe2C4=
github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
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/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
8 changes: 8 additions & 0 deletions migrator/db/clickhouseMigration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ func (s *Migration) GetMigrationHistory(limit int) (db.MigrationEntityList, erro
)
}

if err = rows.Err(); err != nil {
return nil, err
}

return result, nil
}

Expand Down Expand Up @@ -263,5 +267,9 @@ func (s *Migration) getTableScheme() (exists bool, err error) {
}
}

if err = rows.Err(); err != nil {
return false, err
}

return false, nil
}
Loading

0 comments on commit 6272d49

Please sign in to comment.