1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-05-31 21:59:42 +02:00

fix: store table initialization (#2584)

This commit is contained in:
Sagan Yaroslav 2022-10-20 15:59:08 +03:00 committed by GitHub
parent a3980c2308
commit b988a78bae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,11 +61,14 @@ func (s *service) Init(opts ...Option) {
s.opts.Logger.Log(log.FatalLevel, err) s.opts.Logger.Log(log.FatalLevel, err)
} }
// Explicitly set the table name to the service name // If the store has no Table set, fallback to the
name := s.opts.Cmd.App().Name // services name
err := s.opts.Store.Init(store.Table(name)) if len(s.opts.Store.Options().Table) == 0 {
if err != nil { name := s.opts.Cmd.App().Name
s.opts.Logger.Log(log.FatalLevel, err) err := s.opts.Store.Init(store.Table(name))
if err != nil {
s.opts.Logger.Log(log.FatalLevel, err)
}
} }
}) })
} }