Skip to content

Commit e8edcdc

Browse files
authored
Merge branch 'master' into master
2 parents 76efa72 + 691f687 commit e8edcdc

File tree

6 files changed

+102
-105
lines changed

6 files changed

+102
-105
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ Database drivers run migrations. [Add a new database?](database/driver.go)
2828
* [PGX v5](database/pgx/v5)
2929
* [Redshift](database/redshift)
3030
* [Ql](database/ql)
31-
* [Cassandra](database/cassandra)
31+
* [Cassandra / ScyllaDB](database/cassandra)
3232
* [SQLite](database/sqlite)
3333
* [SQLite3](database/sqlite3) ([todo #165](https://github.com/mattes/migrate/issues/165))
3434
* [SQLCipher](database/sqlcipher)
35-
* [MySQL/ MariaDB](database/mysql)
35+
* [MySQL / MariaDB](database/mysql)
3636
* [Neo4j](database/neo4j)
3737
* [MongoDB](database/mongodb)
3838
* [CrateDB](database/crate) ([todo #170](https://github.com/mattes/migrate/issues/170))

database/cassandra/README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
# Cassandra
1+
# Cassandra / ScyllaDB
22

3-
* Drop command will not work on Cassandra 2.X because it rely on
3+
* `Drop()` method will not work on Cassandra 2.X because it rely on
44
system_schema table which comes with 3.X
5-
* Other commands should work properly but are **not tested**
5+
* Other methods should work properly but are **not tested**
66
* The Cassandra driver (gocql) does not natively support executing multiple statements in a single query. To allow for multiple statements in a single migration, you can use the `x-multi-statement` param. There are two important caveats:
77
* This mode splits the migration text into separately-executed statements by a semi-colon `;`. Thus `x-multi-statement` cannot be used when a statement in the migration contains a string with a semi-colon.
88
* The queries are not executed in any sort of transaction/batch, meaning you are responsible for fixing partial migrations.
99

10+
**ScyllaDB**
11+
12+
* No additional configuration is required since it is a drop-in replacement for Cassandra.
13+
* The `Drop()` method` works for ScyllaDB 5.1
14+
1015

1116
## Usage
1217
`cassandra://host:port/keyspace?param1=value&param2=value2`

database/cassandra/cassandra_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ var (
2525
// Although Cassandra 2.x is supported by the Apache Foundation,
2626
// the migrate db driver only supports Cassandra 3.x since it uses
2727
// the system_schema keyspace.
28+
// last ScyllaDB version tested is 5.1.11
2829
specs = []dktesting.ContainerSpec{
2930
{ImageName: "cassandra:3.0", Options: opts},
3031
{ImageName: "cassandra:3.11", Options: opts},
32+
{ImageName: "scylladb/scylla:5.1.11", Options: opts},
3133
}
3234
)
3335

database/clickhouse/clickhouse.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ func (ch *ClickHouse) ensureVersionTable() (err error) {
220220

221221
var (
222222
table string
223-
query = "SHOW TABLES FROM " + ch.config.DatabaseName + " LIKE '" + ch.config.MigrationsTable + "'"
223+
query = "SHOW TABLES FROM " + quoteIdentifier(ch.config.DatabaseName) + " LIKE '" + ch.config.MigrationsTable + "'"
224224
)
225225
// check if migration table exists
226226
if err := ch.conn.QueryRow(query).Scan(&table); err != nil {
@@ -259,7 +259,7 @@ func (ch *ClickHouse) ensureVersionTable() (err error) {
259259
}
260260

261261
func (ch *ClickHouse) Drop() (err error) {
262-
query := "SHOW TABLES FROM " + ch.config.DatabaseName
262+
query := "SHOW TABLES FROM " + quoteIdentifier(ch.config.DatabaseName)
263263
tables, err := ch.conn.Query(query)
264264

265265
if err != nil {
@@ -277,7 +277,7 @@ func (ch *ClickHouse) Drop() (err error) {
277277
return err
278278
}
279279

280-
query = "DROP TABLE IF EXISTS " + ch.config.DatabaseName + "." + table
280+
query = "DROP TABLE IF EXISTS " + quoteIdentifier(ch.config.DatabaseName) + "." + quoteIdentifier(table)
281281

282282
if _, err := ch.conn.Exec(query); err != nil {
283283
return &database.Error{OrigErr: err, Query: []byte(query)}
@@ -305,3 +305,12 @@ func (ch *ClickHouse) Unlock() error {
305305
return nil
306306
}
307307
func (ch *ClickHouse) Close() error { return ch.conn.Close() }
308+
309+
// Copied from lib/pq implementation: https://github.com/lib/pq/blob/v1.9.0/conn.go#L1611
310+
func quoteIdentifier(name string) string {
311+
end := strings.IndexRune(name, 0)
312+
if end > -1 {
313+
name = name[:end]
314+
}
315+
return `"` + strings.Replace(name, `"`, `""`, -1) + `"`
316+
}

go.mod

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
module github.com/golang-migrate/migrate/v4
22

3+
go 1.18
4+
35
require (
4-
cloud.google.com/go/spanner v1.47.0
5-
cloud.google.com/go/storage v1.29.0
6+
cloud.google.com/go/spanner v1.51.0
7+
cloud.google.com/go/storage v1.30.1
68
github.com/Azure/go-autorest/autorest/adal v0.9.16
79
github.com/ClickHouse/clickhouse-go v1.4.3
810
github.com/aws/aws-sdk-go v1.44.301
@@ -34,19 +36,19 @@ require (
3436
github.com/xanzy/go-gitlab v0.15.0
3537
go.mongodb.org/mongo-driver v1.7.5
3638
go.uber.org/atomic v1.7.0
37-
golang.org/x/oauth2 v0.8.0
38-
golang.org/x/tools v0.9.1
39-
google.golang.org/api v0.126.0
39+
golang.org/x/oauth2 v0.14.0
40+
golang.org/x/tools v0.10.0
41+
google.golang.org/api v0.150.0
4042
modernc.org/ql v1.0.0
4143
modernc.org/sqlite v1.18.1
4244
)
4345

4446
require (
45-
cloud.google.com/go v0.110.2 // indirect
46-
cloud.google.com/go/compute v1.19.3 // indirect
47+
cloud.google.com/go v0.110.10 // indirect
48+
cloud.google.com/go/compute v1.23.3 // indirect
4749
cloud.google.com/go/compute/metadata v0.2.3 // indirect
48-
cloud.google.com/go/iam v1.1.0 // indirect
49-
cloud.google.com/go/longrunning v0.5.0 // indirect
50+
cloud.google.com/go/iam v1.1.5 // indirect
51+
cloud.google.com/go/longrunning v0.5.4 // indirect
5052
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
5153
github.com/99designs/keyring v1.2.1 // indirect
5254
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 // indirect
@@ -78,16 +80,16 @@ require (
7880
github.com/cespare/xxhash/v2 v2.2.0 // indirect
7981
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 // indirect
8082
github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe // indirect
81-
github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4 // indirect
83+
github.com/cncf/xds/go v0.0.0-20231109132714-523115ebc101 // indirect
8284
github.com/cznic/mathutil v0.0.0-20180504122225-ca4c9f2c1369 // indirect
8385
github.com/danieljoos/wincred v1.1.2 // indirect
8486
github.com/davecgh/go-spew v1.1.1 // indirect
8587
github.com/docker/distribution v2.8.2+incompatible // indirect
8688
github.com/docker/go-units v0.5.0 // indirect
8789
github.com/dvsekhvalnov/jose2go v1.5.0 // indirect
8890
github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712 // indirect
89-
github.com/envoyproxy/go-control-plane v0.11.1-0.20230524094728-9239064ad72f // indirect
90-
github.com/envoyproxy/protoc-gen-validate v0.10.1 // indirect
91+
github.com/envoyproxy/go-control-plane v0.11.1 // indirect
92+
github.com/envoyproxy/protoc-gen-validate v1.0.2 // indirect
9193
github.com/form3tech-oss/jwt-go v3.2.5+incompatible // indirect
9294
github.com/gabriel-vasile/mimetype v1.4.1 // indirect
9395
github.com/go-stack/stack v1.8.0 // indirect
@@ -101,12 +103,11 @@ require (
101103
github.com/golang/protobuf v1.5.3 // indirect
102104
github.com/golang/snappy v0.0.4 // indirect
103105
github.com/google/flatbuffers v2.0.8+incompatible // indirect
104-
github.com/google/go-cmp v0.5.9 // indirect
105106
github.com/google/go-querystring v1.1.0 // indirect
106-
github.com/google/s2a-go v0.1.4 // indirect
107-
github.com/google/uuid v1.3.0 // indirect
108-
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
109-
github.com/googleapis/gax-go/v2 v2.11.0 // indirect
107+
github.com/google/s2a-go v0.1.7 // indirect
108+
github.com/google/uuid v1.4.0 // indirect
109+
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
110+
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
110111
github.com/gorilla/handlers v1.4.2 // indirect
111112
github.com/gorilla/mux v1.7.4 // indirect
112113
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
@@ -154,19 +155,20 @@ require (
154155
go.opencensus.io v0.24.0 // indirect
155156
golang.org/x/crypto v0.17.0 // indirect
156157
golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0 // indirect
157-
golang.org/x/mod v0.10.0 // indirect
158-
golang.org/x/net v0.17.0 // indirect
159-
golang.org/x/sync v0.2.0 // indirect
158+
golang.org/x/mod v0.11.0 // indirect
159+
golang.org/x/net v0.18.0 // indirect
160+
golang.org/x/sync v0.5.0 // indirect
160161
golang.org/x/sys v0.15.0 // indirect
161162
golang.org/x/term v0.15.0 // indirect
162163
golang.org/x/text v0.14.0 // indirect
164+
golang.org/x/time v0.3.0 // indirect
163165
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
164166
google.golang.org/appengine v1.6.7 // indirect
165-
google.golang.org/genproto v0.0.0-20230530153820-e85fd2cbaebc // indirect
166-
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc // indirect
167-
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
168-
google.golang.org/grpc v1.56.3 // indirect
169-
google.golang.org/protobuf v1.30.0 // indirect
167+
google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b // indirect
168+
google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b // indirect
169+
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect
170+
google.golang.org/grpc v1.59.0 // indirect
171+
google.golang.org/protobuf v1.31.0 // indirect
170172
gopkg.in/inf.v0 v0.9.1 // indirect
171173
gopkg.in/yaml.v3 v3.0.1 // indirect
172174
lukechampine.com/uint128 v1.2.0 // indirect
@@ -188,5 +190,3 @@ require (
188190
modernc.org/token v1.0.0 // indirect
189191
modernc.org/zappy v1.0.0 // indirect
190192
)
191-
192-
go 1.18

0 commit comments

Comments
 (0)