refact(cmd): Encapsulate some functionality on Command and Server
This commit extracts 3 separate pieces of functionality into their own function/method: - Extracts the database opening with the intention to have a function that performs all that functionality but returns the created database object rather than setting it to the Server structure. - Extracts database validation logic, to provide a common code path for upcoming functionality. - Expose schema manager on the Command struct as well as providing common functions to acquire shared lock/close.
This commit is contained in:
1 parent
621f8a9ff2
commit
8ab9ffbcac
6 files changed
+117
-51
No files matched your search
@@ -93,7 +93,7 @@ func (b *Server) CreateDevDatabase(ctx context.Context, opt ...Option) error {
|
||||
b.Info["dev database container"] = strings.TrimPrefix(container, "/")
|
||||
}
|
||||
|
||||
if err := b.ConnectToDatabase(ctx, dialect); err != nil {
|
||||
if err := b.OpenAndSetServerDatabase(ctx, dialect); err != nil {
|
||||
if c != nil {
|
||||
err = multierror.Append(err, c())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user