3bb4ab494e
- Added `internal/db/store.go` to define the Store interface for database operations, including user, organization, app, channel, release, patch, and artifact management. - Introduced `internal/models/models.go` changes to reflect updated organization and artifact response structures. - Created `internal/storage/factory.go`, `local.go`, and `s3.go` to implement storage backends for local filesystem and S3-compatible services. - Removed deprecated `internal/storage/storage.go` and refactored storage interface into `internal/storage/store.go`. - Updated frontend JavaScript in `web/js/app.js` to display server health information, including storage and database backend details.
21 lines
501 B
Go
21 lines
501 B
Go
package db
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
)
|
|
|
|
// NewStore creates the appropriate database backend based on the driver name.
|
|
// Supported drivers: "sqlite" (default), "postgres".
|
|
func NewStore(ctx context.Context, driver, dsn string) (Store, error) {
|
|
switch driver {
|
|
case "postgres", "postgresql", "pg":
|
|
return NewPostgresStore(ctx, dsn)
|
|
default:
|
|
if driver != "" && driver != "sqlite" {
|
|
fmt.Printf("db: unknown driver %q, falling back to sqlite\n", driver)
|
|
}
|
|
return NewSqliteStore(dsn)
|
|
}
|
|
}
|