MCPcopy Index your code
hub / github.com/PatchMon/PatchMon / Open

Function Open

server-source-code/internal/migrate/migrate.go:65–78  ·  view source on GitHub ↗

Open returns a migrate instance using embedded migrations, for use by the CLI (up/down/force/version). Caller must call m.Close() when done.

(databaseURL string)

Source from the content-addressed store, hash-verified

63// Open returns a migrate instance using embedded migrations, for use by the CLI (up/down/force/version).
64// Caller must call m.Close() when done.
65func Open(databaseURL string) (*migrate.Migrate, error) {
66 if databaseURL == "" {
67 return nil, fmt.Errorf("DATABASE_URL is required for migrations")
68 }
69
70 databaseURL = ensureSSLMode(databaseURL)
71
72 source, err := iofs.New(migrationsFS, "migrations")
73 if err != nil {
74 return nil, fmt.Errorf("create embedded migrate source: %w", err)
75 }
76
77 return migrate.NewWithSourceInstance("iofs", source, databaseURL)
78}
79
80func ensureSSLMode(databaseURL string) string {
81 if !strings.Contains(databaseURL, "sslmode=") {

Callers

nothing calls this directly

Calls 1

ensureSSLModeFunction · 0.85

Tested by

no test coverage detected