checkAbort returns abort error if migration was aborted
()
| 445 | |
| 446 | // checkAbort returns abort error if migration was aborted |
| 447 | func (mgtr *Migrator) checkAbort() error { |
| 448 | if abortErr := mgtr.migrationContext.GetAbortError(); abortErr != nil { |
| 449 | return abortErr |
| 450 | } |
| 451 | |
| 452 | ctx := mgtr.migrationContext.GetContext() |
| 453 | if ctx != nil { |
| 454 | select { |
| 455 | case <-ctx.Done(): |
| 456 | // Context cancelled but no abort error stored yet |
| 457 | if abortErr := mgtr.migrationContext.GetAbortError(); abortErr != nil { |
| 458 | return abortErr |
| 459 | } |
| 460 | return ctx.Err() |
| 461 | default: |
| 462 | // Not cancelled |
| 463 | } |
| 464 | } |
| 465 | return nil |
| 466 | } |
| 467 | |
| 468 | // Migrate executes the complete migration logic. This is *the* major gh-ost function. |
| 469 | func (mgtr *Migrator) Migrate() (err error) { |