8000 Merge pull request #434 from symfony-cli/database-url-precedence · symfony-cli/symfony-cli@dbe6914 · GitHub
[go: up one dir, main page]

Skip to content

Commit dbe6914

Browse files
authored
Merge pull request #434 from symfony-cli/database-url-precedence
Rework database URL precedence
2 parents 588fed0 + 8688984 commit dbe6914

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

envs/envs.go

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -158,26 +158,29 @@ func extractRelationshipsEnvs(env Environment) Envs {
158158
}
159159
if detectedLanguage == "php" {
160160
versionKey := fmt.Sprintf("%sVERSION", prefix)
161-
if doctrineConfigVersion, err := platformsh.ReadDBVersionFromDoctrineConfigYAML(env.Path()); err == nil && doctrineConfigVersion != "" {
162-
// configuration from doctrine.yaml
163-
values[versionKey] = doctrineConfigVersion
164-
} else if v, ok := endpoint["type"]; ok {
165-
// type is available when in the cloud or locally via a tunnel
166-
if version, hasVersionInEnv := os.LookupEnv(versionKey); hasVersionInEnv {
167-
values[versionKey] = version
168-
} else if strings.Contains(v.(string), ":") {
169-
version := strings.SplitN(v.(string), ":", 2)[1]
161+
if v, ok := endpoint["type"]; ok {
162+
// configuration from doctrine.yaml takes precedence over psh config
163+
if doctrineConfigVersion, err := platformsh.ReadDBVersionFromDoctrineConfigYAML(env.Path()); err == nil && doctrineConfigVersion != "" {
164+
// configuration from doctrine.yaml
165+
values[versionKey] = doctrineConfigVersion
166+
} else {
167+
// type is available when in the cloud or locally via a tunnel
168+
if version, hasVersionInEnv := os.LookupEnv(versionKey); hasVersionInEnv {
169+
values[versionKey] = version
170+
} else if strings.Contains(v.(string), ":") {
171+
version := strings.SplitN(v.(string), ":", 2)[1]
170172

171-
// we actually provide mariadb not mysql
172-
if endpoint["scheme"].(string) == "mysql" {
173-
minor := 0
174-
if version == "10.2" {
175-
minor = 7
173+
// we actually provide mariadb not mysql
174+
if endpoint["scheme"].(string) == "mysql" {
175+
minor := 0
176+
if version == "10.2" {
177+
minor = 7
178+
}
179+
version = fmt.Sprintf("%s.%d-MariaDB", version, minor)
176180
}
177-
version = fmt.Sprintf("%s.%d-MariaDB", version, minor)
178-
}
179181

180-
values[versionKey] = version
182+
values[versionKey] = version
183+
}
181184
}
182185
} else if env.Local() {
183186
// Docker support

0 commit comments

Comments
 (0)
0