2025-01-06 23:19:03 +01:00
|
|
|
package app
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2025-01-16 13:48:05 +01:00
|
|
|
"git.front.kjuulh.io/kjuulh/orbis/internal/persistence"
|
2025-01-06 23:19:03 +01:00
|
|
|
"git.front.kjuulh.io/kjuulh/orbis/internal/utilities"
|
2025-01-17 20:51:50 +01:00
|
|
|
"github.com/jackc/pgx/v5/pgxpool"
|
2025-01-06 23:19:03 +01:00
|
|
|
)
|
|
|
|
|
2025-01-17 20:51:50 +01:00
|
|
|
var Postgres = utilities.Singleton(func() (*pgxpool.Pool, error) {
|
2025-01-16 13:48:05 +01:00
|
|
|
if err := persistence.Migrate(); err != nil {
|
|
|
|
return nil, fmt.Errorf("failed to migrate database: %w", err)
|
2025-01-06 23:19:03 +01:00
|
|
|
}
|
|
|
|
|
2025-01-16 13:48:05 +01:00
|
|
|
return persistence.NewConnection()
|
2025-01-06 23:19:03 +01:00
|
|
|
})
|