Skip to content

Commit bfaa68e

Browse files
committed
chore: specify an application_name when running migrations
This allows [automated] migrations activity to be differentiated from user-initiated activity.
1 parent d54fe40 commit bfaa68e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cmd/migrate_cmd.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cmd
22

33
import (
4+
"fmt"
45
"net/url"
56
"os"
67

@@ -53,9 +54,16 @@ func migrate(cmd *cobra.Command, args []string) {
5354
}
5455
}
5556

57+
u, err := url.Parse(globalConfig.DB.URL)
58+
processedUrl := globalConfig.DB.URL
59+
if len(u.Query()) != 0 {
60+
processedUrl = fmt.Sprintf("%s&application_name=gotrue_migrations", processedUrl)
61+
} else {
62+
processedUrl = fmt.Sprintf("%s?application_name=gotrue_migrations", processedUrl)
63+
}
5664
deets := &pop.ConnectionDetails{
5765
Dialect: globalConfig.DB.Driver,
58-
URL: globalConfig.DB.URL,
66+
URL: processedUrl,
5967
}
6068
deets.Options = map[string]string{
6169
"migration_table_name": "schema_migrations",

0 commit comments

Comments
 (0)