migrate: Add support CQL comment callbacks
This patch adds a new migration event type CallComment that it triggered by adding `-- CALL <name>;` comment in a CQL file. Fixes #101
This commit is contained in:
committed by
Michal Jan Matczuk
parent
41e4a3fa11
commit
d25129e2fc
@@ -17,12 +17,17 @@ type CallbackEvent uint8
|
||||
const (
|
||||
BeforeMigration CallbackEvent = iota
|
||||
AfterMigration
|
||||
CallComment
|
||||
)
|
||||
|
||||
// CallbackFunc enables interrupting the migration process and executing code
|
||||
// while migrating. If error is returned the migration is aborted.
|
||||
// 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).
|
||||
type CallbackFunc func(ctx context.Context, session gocqlx.Session, ev CallbackEvent, name string) error
|
||||
|
||||
// Callback is called before and after each migration.
|
||||
// Callback is means of executing Go code during migrations.
|
||||
// Use this variable to register a global callback dispatching function.
|
||||
// See CallbackFunc for details.
|
||||
var Callback CallbackFunc
|
||||
|
||||
Reference in New Issue
Block a user