From f2e60182df7cd24f72676d9bf1fc20ae9336f47b Mon Sep 17 00:00:00 2001 From: timerzz Date: Tue, 14 May 2024 17:04:27 +0800 Subject: [PATCH] feat AutoMigrate --- product/controller.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/product/controller.go b/product/controller.go index cdf58df..0dfcc4d 100644 --- a/product/controller.go +++ b/product/controller.go @@ -29,6 +29,11 @@ func NewController(client *coach_client.Client, db *gorm.DB) *Controller { return ctl } +func (c *Controller) AutoMigrate() { + if err := c.db.AutoMigrate(&database.Product{}, &database.HistoryPrice{}, &Option{}); err != nil { + panic(err) + } +} func (c *Controller) Run(ctx context.Context) { c.ctx = ctx ticker := time.NewTicker(c.Interval)