1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-01-17 17:44:30 +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)
}
// Explicitly set the table name to the service name
name := s.opts.Cmd.App().Name
err := s.opts.Store.Init(store.Table(name))
if err != nil {
s.opts.Logger.Log(log.FatalLevel, err)
// If the store has no Table set, fallback to the
// services name
if len(s.opts.Store.Options().Table) == 0 {
name := s.opts.Cmd.App().Name
err := s.opts.Store.Init(store.Table(name))
if err != nil {
s.opts.Logger.Log(log.FatalLevel, err)
}
}
})
}