Skip to content

Commit 60d4844

Browse files
committed
Fix Clickhouse driver to work correctly with v2
1 parent 691bc77 commit 60d4844

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

database/clickhouse/clickhouse.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,14 @@ func (ch *ClickHouse) SetVersion(version int, dirty bool) error {
193193
}
194194

195195
query := "INSERT INTO " + ch.config.MigrationsTable + " (version, dirty, sequence) VALUES (?, ?, ?)"
196-
if _, err := tx.Exec(query, version, bool(dirty), time.Now().UnixNano()); err != nil {
196+
stmt, err := tx.Prepare(query)
197+
if err != nil {
198+
if rollbackErr := tx.Rollback(); rollbackErr != nil {
199+
return fmt.Errorf("error during prepare statement %w and rollback %s", err, rollbackErr)
200+
}
201+
return err
202+
}
203+
if _, err := stmt.Exec(int64(version), bool(dirty), uint64(time.Now().UnixNano())); err != nil {
197204
return &database.Error{OrigErr: err, Query: []byte(query)}
198205
}
199206

0 commit comments

Comments
 (0)