From 5b38ecced5a9c910be97b32f7f910a5c14709d3c Mon Sep 17 00:00:00 2001 From: Jamie Date: Thu, 7 Dec 2023 16:59:55 +1300 Subject: [PATCH] disconnect on fail --- .../20231128_jellyfish_migration.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/migrations/20231128_jellyfish_migration/20231128_jellyfish_migration.go b/migrations/20231128_jellyfish_migration/20231128_jellyfish_migration.go index 2811f0e0e..7f637eb9b 100644 --- a/migrations/20231128_jellyfish_migration/20231128_jellyfish_migration.go +++ b/migrations/20231128_jellyfish_migration/20231128_jellyfish_migration.go @@ -73,7 +73,7 @@ func (m *Migration) RunAndExit() { } m.CLI().Action = func(ctx *cli.Context) error { - log.Println("prepare") + log.Println("running") var err error m.client, err = mongo.Connect(m.ctx, options.Client().ApplyURI(m.config.uri)) if err != nil { @@ -95,6 +95,10 @@ func (m *Migration) RunAndExit() { } if err := m.CLI().Run(os.Args); err != nil { + if m.client != nil { + m.client.Disconnect(m.ctx) + } + os.Exit(1) } }