예제 #1
0
func (b *BDR) DropDatabase(dbname string) (err error) {
	nodes, err := b.PGNodes()
	if err != nil {
		log.Error(fmt.Sprintf(`bdr.BDR#DropDatabase(%s) ! %s`, dbname, err))
	}

	for i := len(nodes) - 1; i >= 0; i-- {
		pg := nodes[i]
		pg.Set(`database`, `postgres`)
		err = pg.DropDatabase(dbname)
		if err != nil {
			log.Error(fmt.Sprintf("bdr.BDR<%s>#DropDatabase(%s) ! %s", pg.IP, dbname, err))
		}
	}
	return nil
}
예제 #2
0
func (b *BDR) DropDatabase(dbname string) (err error) {
	if err != nil {
		log.Error(fmt.Sprintf(`bdr.BDR#DropDatabase(%s) DropDatabase() ! %s`, dbname, err))
	}

	nodes, err := b.PGNodes()
	if err != nil {
		log.Error(fmt.Sprintf(`bdr.BDR#DropDatabase(%s) ! %s`, dbname, err))
	}

	for i := len(nodes) - 1; i >= 0; i-- {
		pg := nodes[i]
		err := pg.BDRDisableDatabase(dbname)
		if err != nil {
			log.Error(fmt.Sprintf("bdr.BDR<%s>#DropDatabase(%s) pg.BDRDisableDatabase() ! %s", pg.IP, dbname, err))
			return err
		}
		err = pg.DropDatabase(dbname)
		if err != nil {
			log.Error(fmt.Sprintf("bdr.BDR<%s>#DropDatabase(%s) pg.DropDatabase() ! %s", pg.IP, dbname, err))
		}
	}
	return nil
}