Files
UNITRONIX e855f5786d Add Go server and security audit; update web console
Add a new betterdesk-server Go codebase (server, api, auth, db, relay, signal, metrics, audit, ratelimit, proto, tools, tests) and related deployment/migration scripts. Add a comprehensive SECURITY_AUDIT_2026-03-01 report and .gitattributes; update copilot-instructions (ALL-IN-ONE v2.4.0), README, VERSION, Dockerfiles, scripts, docker-compose and entrypoint. Large updates to web-nodejs (translations, routes, services, frontend assets and middleware) and numerous new utilities; remove legacy Flask web files and archive hbbs-patch-v2 artifacts. Prepares repository for PostgreSQL support, DB migration tooling and the new Go server as the production backend.
2026-03-02 00:43:04 +01:00

23 lines
686 B
Go

// Package db — convenience constructors.
package db
import "strings"
// Open opens a database at the given DSN.
//
// If dsn starts with "postgres://" or "postgresql://" the PostgreSQL driver
// is used (pgx/v5). Otherwise the dsn is treated as a local file path and
// the SQLite driver is used.
//
// Examples:
//
// db.Open("db_v2.sqlite3") // SQLite (default)
// db.Open("postgres://user:pass@localhost/betterdesk") // PostgreSQL
func Open(dsn string) (Database, error) {
lower := strings.ToLower(dsn)
if strings.HasPrefix(lower, "postgres://") || strings.HasPrefix(lower, "postgresql://") {
return OpenPostgres(dsn)
}
return OpenSQLite(dsn)
}