github.com/mpontillo/pop@v4.13.1+incompatible/commands.go (about) 1 package pop 2 3 import ( 4 "fmt" 5 6 "github.com/gobuffalo/pop/logging" 7 "github.com/pkg/errors" 8 ) 9 10 // CreateDB creates a database, given a connection definition 11 func CreateDB(c *Connection) error { 12 deets := c.Dialect.Details() 13 if deets.Database != "" { 14 log(logging.Info, fmt.Sprintf("create %s (%s)", deets.Database, c.URL())) 15 return errors.Wrapf(c.Dialect.CreateDB(), "couldn't create database %s", deets.Database) 16 } 17 return nil 18 } 19 20 // DropDB drops an existing database, given a connection definition 21 func DropDB(c *Connection) error { 22 deets := c.Dialect.Details() 23 if deets.Database != "" { 24 log(logging.Info, fmt.Sprintf("drop %s (%s)", deets.Database, c.URL())) 25 return errors.Wrapf(c.Dialect.DropDB(), "couldn't drop database %s", deets.Database) 26 } 27 return nil 28 }