mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-11-05 11:22:18 +00:00
refactor: Remove inline schema creation from PostgresProfileStore in favor of centralized migration system
- Remove AutoMigrate call for profileRow from NewPostgresProfileStore - Update function comment to reference migration system (make db-migrate) instead of inline schema creation - Add note that esim_profiles table is created by migration system - Remove error handling for AutoMigrate execution
This commit is contained in:
@@ -34,8 +34,8 @@ type PostgresProfileStore struct {
|
|||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPostgresProfileStore connects to Postgres using the given DSN, runs the
|
// NewPostgresProfileStore connects to Postgres using the given DSN and returns a repository ready to use.
|
||||||
// profile schema migration, and returns a repository ready to use.
|
// Note: Database schema should be created by running migrations via `make db-migrate`
|
||||||
func NewPostgresProfileStore(dsn string) (*PostgresProfileStore, error) {
|
func NewPostgresProfileStore(dsn string) (*PostgresProfileStore, error) {
|
||||||
if dsn == "" {
|
if dsn == "" {
|
||||||
return nil, errors.New("postgres DSN is empty")
|
return nil, errors.New("postgres DSN is empty")
|
||||||
@@ -46,9 +46,8 @@ func NewPostgresProfileStore(dsn string) (*PostgresProfileStore, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("open postgres: %w", err)
|
return nil, fmt.Errorf("open postgres: %w", err)
|
||||||
}
|
}
|
||||||
if err := db.AutoMigrate(&profileRow{}); err != nil {
|
// Note: AutoMigrate removed - schema managed by migration system
|
||||||
return nil, fmt.Errorf("migrate esim_profiles: %w", err)
|
// Run `make db-migrate` to create/update database schema
|
||||||
}
|
|
||||||
return &PostgresProfileStore{db: db}, nil
|
return &PostgresProfileStore{db: db}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user