In the production server with Beego I get
must have one register DataBase alias named default
I know the db connection credentials work in the server but whenever I do restful request I get this error and the Beego server crashes.
Is there a reason why this is happening?
Below is the code inside main.go init function:
orm.RegisterDriver("postgres", orm.DR_Postgres)
orm.RegisterDataBase("default", "postgres",
fmt.Sprintf("postgres://%s:%s@%s/%s?port=%i",
pgUser, pgPass, pgHost, pgDb, pgPort))
Can you provide a sample of your code?
Based on the error message you have provided, you may not have registered a database with alias
default
usingorm.RegisterDataBase
. Here's an example which I have taken from the documentation:In beego, it is common to register the driver and the database in
init
ofmain.go
(example).