forked from gobuffalo/pop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.go
28 lines (24 loc) · 776 Bytes
/
commands.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package pop
import (
"fmt"
"github.com/gobuffalo/pop/v5/logging"
"github.com/pkg/errors"
)
// CreateDB creates a database, given a connection definition
func CreateDB(c *Connection) error {
deets := c.Dialect.Details()
if deets.Database != "" {
log(logging.Info, fmt.Sprintf("create %s (%s)", deets.Database, c.URL()))
return errors.Wrapf(c.Dialect.CreateDB(), "couldn't create database %s", deets.Database)
}
return nil
}
// DropDB drops an existing database, given a connection definition
func DropDB(c *Connection) error {
deets := c.Dialect.Details()
if deets.Database != "" {
log(logging.Info, fmt.Sprintf("drop %s (%s)", deets.Database, c.URL()))
return errors.Wrapf(c.Dialect.DropDB(), "couldn't drop database %s", deets.Database)
}
return nil
}