You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: enable.go
    path of file: ./repos/porter/cmd/migrate/enable_cluster_preview_envs
    
    the code of the file until where you have to start completion: package enable_cluster_preview_envs

import (
	"github.com/porter-dev/porter/internal/features"
	"github.com/porter-dev/porter/internal/models"
	lr "github.com/porter-dev/porter/pkg/logger"
	_gorm "gorm.io/gorm"
)

// EnableClusterPreviewEnvs enables preview environments for clusters where it is enabled for the project
func EnableClusterPreviewEnvs(db *_gorm.DB, client *features.Client, logger *lr.Logger) error {
	logger.Info().Msg("starting to enable preview envs for existing clusters whose parent projects have preview envs enabled")

	var clusters []*models.Cluster

	if err := db.Find(&clusters).Error; err != nil {
		logger.Error().Msgf("fai
    
func EnableClusterPreviewEnvs(db *_gorm.DB, client *features.Client, logger *lr.Logger) error {
	logger.Info().Msg("starting to enable preview envs for existing clusters whose parent projects have preview envs enabled")

	var clusters []*models.Cluster

	if err := db.Find(&clusters).Error; err != nil {
		logger.Error().Msgf("failed to get clusters: %v", err)
		return err
	}

	for _, c := range clusters {
		project := &models.Project{}

		if err := db.Model(project).Where("id = ?", c.ProjectID).First(project).Error; err != nil {
			logger.Error().Msgf("failed to get project ID %d for cluster ID %d: %v", c.ProjectID, c.ID, err)
			continue
		}

		if project.GetFeatureFlag(models.PreviewEnvsEnabled, client) {
			c.PreviewEnvsEnabled = true

			if err := db.Save(c).Error; err != nil {
				logger.Error().Msgf("failed to update cluster ID %d: %v", c.ID, err)
				return err
			}

			logger.Info().Msgf("enabled preview envs for cluster ID %d", c.ID)
		}
	}

	logger.Info().Msg("cluster preview envs migration completed")

	return nil
}