code: func (m *Migrator) fetchMigrations() error {
  	pathGlob := append([]byte(m.MigrationsPath), []byte("*")...)
  
  	matches, err := filepath.Glob(string(pathGlob))
  	if err != nil {
  		m.logger.Fatalf("Error while globbing migrations: %v", err)
  	}
  
  	for _, match := range matches {
  		num, migrationType, name, err := parseMigrationPath(match)
  		if err != nil {
  			m.logger.Printf("Invalid migration file found: %s", match)
  			continue
  		}
  
  		m.logger.Printf("Migration file found: %s", match)
  
  		migration, ok := m.migrations[num]
  		if !ok {
  			migration = &Migration{Id: num, Name: name, Status: Inactive}
  			m.migrations[num] = migration
  		}
  		if migrationType == upMigration {
  			migration.UpPath = match
  		} else {
  			migration.DownPath = match
  		}
  	}
  
  	// Validate each migration.
  	for _, migration := range m.migrations {
  		if !migration.valid() {
  			path := migration.UpPath
  			if path == "" {
  				path = migration.DownPath
  			}
  			m.logger.Printf("Invalid migration pair for path: %s", path)
  			return InvalidMigrationPair
  		}
  	}
  
  	m.logger.Printf("Migrations file pairs found: %v", len(m.migrations))
  
  	return nil
  }
docs: // Populates a migrator with a sorted list of migrations from the file system.