Skip to content

Commit 6a5ad41

Browse files
committed
refactor: Standardize import aliases
1 parent 576cfe7 commit 6a5ad41

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

cmd/migrate.go

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import (
55
"fmt"
66
"os"
77

8-
"github.com/inference-gateway/cli/internal/container"
9-
"github.com/inference-gateway/cli/internal/infra/storage"
10-
"github.com/inference-gateway/cli/internal/infra/storage/migrations"
11-
"github.com/inference-gateway/cli/internal/ui/styles/icons"
12-
"github.com/spf13/cobra"
8+
container "github.com/inference-gateway/cli/internal/container"
9+
storage "github.com/inference-gateway/cli/internal/infra/storage"
10+
migrations "github.com/inference-gateway/cli/internal/infra/storage/migrations"
11+
icons "github.com/inference-gateway/cli/internal/ui/styles/icons"
12+
cobra "github.com/spf13/cobra"
1313
)
1414

1515
var migrateCmd = &cobra.Command{
@@ -39,34 +39,27 @@ func init() {
3939

4040
// runMigrations executes pending database migrations
4141
func runMigrations() error {
42-
// Get configuration from global viper
4342
cfg, err := getConfigFromViper()
4443
if err != nil {
4544
return fmt.Errorf("failed to get config: %w", err)
4645
}
4746

48-
// Create service container
4947
serviceContainer := container.NewServiceContainer(cfg, V)
5048

51-
// Get storage backend
5249
conversationStorage := serviceContainer.GetStorage()
5350

54-
// Close storage when done
5551
defer func() {
5652
if err := conversationStorage.Close(); err != nil {
5753
fmt.Fprintf(os.Stderr, "Warning: failed to close storage: %v\n", err)
5854
}
5955
}()
6056

61-
// Get underlying database connection
6257
switch conversationStorage.(type) {
6358
case *storage.SQLiteStorage:
64-
// Migrations are automatically run during NewSQLiteStorage
6559
fmt.Printf("%s SQLite database migrations are up to date\n", icons.CheckMarkStyle.Render(icons.CheckMark))
6660
fmt.Println(" All migrations have been applied automatically")
6761
return nil
6862
case *storage.PostgresStorage:
69-
// Migrations are automatically run during NewPostgresStorage
7063
fmt.Printf("%s PostgreSQL database migrations are up to date\n", icons.CheckMarkStyle.Render(icons.CheckMark))
7164
fmt.Println(" All migrations have been applied automatically")
7265
return nil
@@ -86,26 +79,21 @@ func runMigrations() error {
8679

8780
// showMigrationStatus displays the current migration status
8881
func showMigrationStatus() error {
89-
// Get configuration from global viper
9082
cfg, err := getConfigFromViper()
9183
if err != nil {
9284
return fmt.Errorf("failed to get config: %w", err)
9385
}
9486

95-
// Create service container
9687
serviceContainer := container.NewServiceContainer(cfg, V)
9788

98-
// Get storage backend
9989
conversationStorage := serviceContainer.GetStorage()
10090

101-
// Close storage when done
10291
defer func() {
10392
if err := conversationStorage.Close(); err != nil {
10493
fmt.Fprintf(os.Stderr, "Warning: failed to close storage: %v\n", err)
10594
}
10695
}()
10796

108-
// Check storage type and show status
10997
switch s := conversationStorage.(type) {
11098
case *storage.SQLiteStorage:
11199
return showSQLiteMigrationStatus(s)
@@ -128,7 +116,7 @@ func showMigrationStatus() error {
128116
// showSQLiteMigrationStatus shows migration status for SQLite
129117
func showSQLiteMigrationStatus(s *storage.SQLiteStorage) error {
130118
ctx := context.Background()
131-
db := s.DB() // We'll need to expose this
119+
db := s.DB()
132120
if db == nil {
133121
return fmt.Errorf("database connection is nil")
134122
}
@@ -159,7 +147,7 @@ func showSQLiteMigrationStatus(s *storage.SQLiteStorage) error {
159147
// showPostgresMigrationStatus shows migration status for PostgreSQL
160148
func showPostgresMigrationStatus(s *storage.PostgresStorage) error {
161149
ctx := context.Background()
162-
db := s.DB() // We'll need to expose this
150+
db := s.DB()
163151
if db == nil {
164152
return fmt.Errorf("database connection is nil")
165153
}

0 commit comments

Comments
 (0)