Skip to content

Commit

Permalink
Merge pull request #434 from symfony-cli/database-url-precedence
Browse files Browse the repository at this point in the history
Rework database URL precedence
  • Loading branch information
fabpot committed Feb 9, 2024
2 parents 588fed0 + 8688984 commit dbe6914
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions envs/envs.go
Expand Up @@ -158,26 +158,29 @@ func extractRelationshipsEnvs(env Environment) Envs {
}
if detectedLanguage == "php" {
versionKey := fmt.Sprintf("%sVERSION", prefix)
if doctrineConfigVersion, err := platformsh.ReadDBVersionFromDoctrineConfigYAML(env.Path()); err == nil && doctrineConfigVersion != "" {
// configuration from doctrine.yaml
values[versionKey] = doctrineConfigVersion
} else if v, ok := endpoint["type"]; ok {
// type is available when in the cloud or locally via a tunnel
if version, hasVersionInEnv := os.LookupEnv(versionKey); hasVersionInEnv {
values[versionKey] = version
} else if strings.Contains(v.(string), ":") {
version := strings.SplitN(v.(string), ":", 2)[1]
if v, ok := endpoint["type"]; ok {
// configuration from doctrine.yaml takes precedence over psh config
if doctrineConfigVersion, err := platformsh.ReadDBVersionFromDoctrineConfigYAML(env.Path()); err == nil && doctrineConfigVersion != "" {
// configuration from doctrine.yaml
values[versionKey] = doctrineConfigVersion
} else {
// type is available when in the cloud or locally via a tunnel
if version, hasVersionInEnv := os.LookupEnv(versionKey); hasVersionInEnv {
values[versionKey] = version
} else if strings.Contains(v.(string), ":") {
version := strings.SplitN(v.(string), ":", 2)[1]

// we actually provide mariadb not mysql
if endpoint["scheme"].(string) == "mysql" {
minor := 0
if version == "10.2" {
minor = 7
// we actually provide mariadb not mysql
if endpoint["scheme"].(string) == "mysql" {
minor := 0
if version == "10.2" {
minor = 7
}
version = fmt.Sprintf("%s.%d-MariaDB", version, minor)
}
version = fmt.Sprintf("%s.%d-MariaDB", version, minor)
}

values[versionKey] = version
values[versionKey] = version
}
}
} else if env.Local() {
// Docker support
Expand Down

0 comments on commit dbe6914

Please sign in to comment.