-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Migrate from gocql v1.x to v2 #1321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Migrate from gocql v1.x to v2 #1321
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> 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 |
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