2018-05-23 15:15:06 +02:00
|
|
|
// Copyright (C) 2017 ScyllaDB
|
|
|
|
|
// Use of this source code is governed by a ALv2-style
|
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
package migrate
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
2020-04-29 09:50:30 +02:00
|
|
|
"github.com/scylladb/gocqlx/v2"
|
2018-05-23 15:15:06 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// CallbackEvent specifies type of the event when calling CallbackFunc.
|
|
|
|
|
type CallbackEvent uint8
|
|
|
|
|
|
|
|
|
|
// enumeration of CallbackEvents
|
|
|
|
|
const (
|
|
|
|
|
BeforeMigration CallbackEvent = iota
|
|
|
|
|
AfterMigration
|
2020-12-02 13:18:49 +01:00
|
|
|
CallComment
|
2018-05-23 15:15:06 +02:00
|
|
|
)
|
|
|
|
|
|
2020-12-02 13:18:49 +01:00
|
|
|
// CallbackFunc enables execution of arbitrary Go code during migration.
|
|
|
|
|
// If error is returned the migration is aborted.
|
|
|
|
|
// BeforeMigration and AfterMigration are triggered before and after processing
|
|
|
|
|
// of each migration file respectively.
|
|
|
|
|
// CallComment is triggered for each comment in a form `-- CALL <name>;` (note the semicolon).
|
2020-04-20 17:39:17 +02:00
|
|
|
type CallbackFunc func(ctx context.Context, session gocqlx.Session, ev CallbackEvent, name string) error
|
2018-05-23 15:15:06 +02:00
|
|
|
|
2020-12-02 13:18:49 +01:00
|
|
|
// Callback is means of executing Go code during migrations.
|
|
|
|
|
// Use this variable to register a global callback dispatching function.
|
2018-05-23 15:15:06 +02:00
|
|
|
// See CallbackFunc for details.
|
|
|
|
|
var Callback CallbackFunc
|