MCPcopy Create free account
hub / github.com/Scalingo/cli / Destroy

Function Destroy

dbng/destroy.go:12–47  ·  view source on GitHub ↗
(ctx context.Context, appID string)

Source from the content-addressed store, hash-verified

10)
11
12func Destroy(ctx context.Context, appID string) error {
13 c, err := config.ScalingoClient(ctx)
14 if err != nil {
15 return errors.Wrap(ctx, err, "get Scalingo client")
16 }
17
18 db, err := c.Preview().DatabaseShow(ctx, appID)
19 if err != nil {
20 return errors.Wrap(ctx, err, "delete database")
21 }
22
23 io.Warningf("You're going to delete database %s ('%s'),\n", db.ID, db.Name)
24 io.Warning()
25 io.Warning("This operation is irreversible, all data including backups of your database will be deleted.")
26
27 fmt.Print("\nTo confirm type the ID or the name of the database: ")
28 var validationID string
29 _, err = fmt.Scan(&validationID)
30 if err != nil {
31 return errors.Wrap(ctx, err, "delete database confirmation")
32 }
33 fmt.Println()
34
35 if validationID != db.ID && validationID != db.Name {
36 return errors.Newf(ctx, "'%s' is not the ID or the name of the database, aborting…\n", validationID)
37 }
38
39 err = c.Preview().DatabaseDestroy(ctx, appID)
40 if err != nil {
41 return errors.Wrap(ctx, err, "delete database")
42 }
43
44 io.Statusf("The database %s has been deleted.", db.ID)
45
46 return nil
47}

Callers 1

databases_ng.goFile · 0.92

Calls 4

ScalingoClientFunction · 0.92
WarningfFunction · 0.92
WarningFunction · 0.92
StatusfFunction · 0.92

Tested by

no test coverage detected