Ejemplo n.º 1
0
func initCoreDb(app *App) {
	repo, err := db2.Open(app.config.StellarCoreDatabaseURL)

	if err != nil {
		log.Panic(err)
	}

	repo.DB.SetMaxIdleConns(4)
	repo.DB.SetMaxOpenConns(12)
	app.coreQ = &core.Q{repo}
}
Ejemplo n.º 2
0
func initHorizonDb(app *App) {
	repo, err := db2.Open(app.config.DatabaseURL)

	if err != nil {
		log.Panic(err)
	}
	repo.DB.SetMaxIdleConns(4)
	repo.DB.SetMaxOpenConns(12)

	app.historyQ = &history.Q{repo}
}
Ejemplo n.º 3
0
Archivo: db.go Proyecto: irisli/horizon
	"github.com/stellar/horizon/db2/schema"
	"github.com/stellar/horizon/ingest"
	hlog "github.com/stellar/horizon/log"
)

var dbCmd = &cobra.Command{
	Use:   "db [command]",
	Short: "commands to manage horizon's postgres db",
}

var dbInitCmd = &cobra.Command{
	Use:   "init",
	Short: "install schema",
	Long:  "init initializes the postgres database used by horizon.",
	Run: func(cmd *cobra.Command, args []string) {
		db, err := db2.Open(viper.GetString("db-url"))
		if err != nil {
			hlog.Error(err)
			os.Exit(1)
		}

		err = schema.Init(db)
		if err != nil {
			hlog.Error(err)
			os.Exit(1)
		}
	},
}

var dbMigrateCmd = &cobra.Command{
	Use:   "migrate [up|down|redo] [COUNT]",