code: func PopulateCommonTypes(ctx context.Context, db *gorm.DB) error {
  	populateLocker.Lock()
  	defer populateLocker.Unlock()
  
  	// Create or update space templates
  	templateFunctions := []func() (*importer.ImportHelper, error){
  		importer.BaseTemplate,
  		importer.LegacyTemplate,
  		importer.ScrumTemplate,
  		importer.AgileTemplate,
  	}
  	importRepo := importer.NewRepository(db)
  	for idx, loadFunction := range templateFunctions {
  		log.Debug(ctx, nil, `importing space template #%d`, idx)
  		t, err := loadFunction()
  		if err != nil {
  			return errs.Wrapf(err, `failed to load space template #%d`, idx)
  		}
  		_, err = importRepo.Import(ctx, *t)
  		if err != nil {
  			log.Error(ctx, map[string]interface{}{
  				"err":  err,
  				"id":   t.Template.ID,
  				"name": t.Template.Name,
  			}, `failed to import space template #%d with name "%s" and ID %s`, idx, t.Template.Name, t.Template.ID)
  			return errs.Wrapf(err, `failed to import space template #%d with name "%s" and ID %s`, idx, t.Template.Name, t.Template.ID)
  		}
  		log.Debug(ctx, nil, `imported space template #%d "%s"`, idx, t.Template.Name)
  	}
  	workitem.ClearGlobalWorkItemTypeCache() // Clear the WIT cache after updating existing WITs
  	return nil
  }
docs: // PopulateCommonTypes makes sure the database is populated with the correct types (e.g. bug etc.)