Files
shorebird-server/internal/db/factory.go
T
Tony 3bb4ab494e feat: implement database and storage abstractions
- 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.
2026-06-12 08:45:01 +08:00

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)
}
}