Sanjay Prajapat
Sanjay Prajapat

Reputation: 305

How to do database migration from source code with Beego framework?

I am using Beego framework in Golang. Whenever I add new table or column to the database, I want the code to do the migration. Is there any flag I can specify in code to migrate the database automatically in new release?

I don't want to run this bee migrate -conn="username:password@tcp(127.0.0.1:3306)/mydb" whenever I make db changes.

Upvotes: 0

Views: 281

Answers (1)

mhutter
mhutter

Reputation: 2916

I think you want to use orm.RunSyncdb:

err := orm.RunSyncdb("default", false, true)

See Documentation: https://beego.me/docs/mvc/model/orm.md#generate-tables

Upvotes: 0

Related Questions