Example #1
0
func (srv *Server) getMd(md metadata.LookupSaver) error {
	srv.log.Debug("getting database handle")

	if md == nil {
		mddb, err := metadata.NewDatabase(srv.opts.DatabaseURL, srv.log)

		if err != nil {
			return err
		}

		err = mddb.Init()
		if err != nil {
			return err
		}

		md = mddb
	}

	srv.md = md
	return nil
}
Example #2
0
// MigratorMain is the entry point for the "migrate" cli command
func MigratorMain(log *logrus.Logger) {
	opts := NewOptions()
	if opts.Debug {
		log.Level = logrus.DebugLevel
	}

	log.Debug("spinning up database")

	db, err := metadata.NewDatabase(opts.DatabaseURL, log)
	if err != nil {
		log.Fatal(err)
	}

	log.Debug("migrating")

	err = db.Migrate(log)
	if err != nil {
		log.Fatal(err)
	}

	log.Info("database migration complete")
}