@@ -55,59 +55,6 @@ func (e ErrDirty) Error() string {
5555 return fmt .Sprintf ("Dirty database version %v. Fix and force version." , e .Version )
5656}
5757
58- // MigrationTask is a callback function type that can be used to execute a
59- // Golang based migration step after a SQL based migration step has been
60- // executed. The callback function receives the migration and the database
61- // driver as arguments.
62- type MigrationTask func (migr * Migration , driver database.Driver ) error
63-
64- // options is a set of optional options that can be set when a Migrate instance
65- // is created.
66- type options struct {
67- // tasks is a map of MigrationTask functions that can be used to execute
68- // a Golang based migration step after a SQL based migration step ha
69- // been executed. The key is the migration version and the value is the
70- // callback function that should be run _after_ the step was executed
71- // (but within the same database transaction).
72- tasks map [uint ]MigrationTask
73- }
74-
75- // defaultOptions returns a new options struct with default values.
76- func defaultOptions () options {
77- return options {
78- tasks : make (map [uint ]MigrationTask ),
79- }
80- }
81-
82- // Option is a function that can be used to set options on a Migrate instance.
83- type Option func (* options )
84-
85- // WithMigrationTasks is an option that can be used to set a map of
86- // MigrationTask functions that can be used to execute a Golang based migration
87- // step after a SQL based migration step has been executed. The key is the
88- // migration version and the value is the task function that should be run
89- // _after_ the step was executed (but before the version is marked as cleanly
90- // executed). An error returned from the task will cause the migration to fail
91- // and the step to be marked as dirty.
92- func WithMigrationTasks (tasks map [uint ]MigrationTask ) Option {
93- return func (o * options ) {
94- o .tasks = tasks
95- }
96- }
97-
98- // WithMigrationTask is an option that can be used to set a MigrationTask
99- // function that can be used to execute a Golang based migration step after the
100- // SQL based migration step with the given version number has been executed. The
101- // task is the function that should be run _after_ the step was executed
102- // (but before the version is marked as cleanly executed). An error returned
103- // from the task will cause the migration to fail and the step to be marked as
104- // dirty.
105- func WithMigrationTask (version uint , task MigrationTask ) Option {
106- return func (o * options ) {
107- o .tasks [version ] = task
108- }
109- }
110-
11158type Migrate struct {
11259 sourceName string
11360 sourceDrv source.Driver
0 commit comments