Migrate from gocql v1.x to v2#1321
Migrate from gocql v1.x to v2#1321tejaslodayadd wants to merge 2 commits intogolang-migrate:masterfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR migrates the Cassandra driver from the deprecated github.com/gocql/gocql v1.x to the newer github.com/apache/cassandra-gocql-driver/v2 v2.0.0, following the Apache Cassandra gocql driver upgrade guide.
Key changes:
- Updated module dependency from
gocql/gocqltoapache/cassandra-gocql-driver/v2 - Replaced import statements across Cassandra database implementation files
- Updated documentation to reflect protocol version 5 support
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| go.mod | Added new v2 driver dependency, removed old gocql dependency and transitive dependencies |
| database/cassandra/cassandra.go | Updated import to use aliased v2 driver |
| database/cassandra/cassandra_test.go | Updated imports with proper organization and v2 driver alias |
| database/cassandra/README.md | Updated protocol version documentation to include version 5 |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if _, ok := err.(*gocql.Error); ok { | ||
| return database.NilVersion, false, nil | ||
| } |
There was a problem hiding this comment.
> golangci-lint run ./database/cassandra/...
database/cassandra/cassandra.go:283:21: SA1019: gocql.Error is deprecated: Unused (staticcheck)
if _, ok := err.(*gocql.Error); ok {
The code is checking for *gocql.Error which is deprecated in v2. Looking at the context, this check appears to be trying to handle the case where the table doesn't exist yet. However, since ensureVersionTable() is always called before Version() (as seen in line 78-80), the table should already exist, making this check unnecessary.
|
CC: @dhui pls feel free to leave comments |
|
@dhui any updates on this? |
|
@dhui can you please revisit this PR? @tejaslodayadd will you have time to rebase to the latest master? |
|
@marknefedov thanks for the bump! But I'm not sure if I will get a response from @dhui |
gocql has recently upgraded from v1.x to v2 with some breaking changes.
Upgrade guide: https://github.com/apache/cassandra-gocql-driver/blob/trunk/UPGRADE_GUIDE.md
We'd like to change this and have it as part of golang-migrate/migrate