mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 07:32:32 +01:00
feat: add SQLite support, setup wizard enhancements, and live dashboard
Add zero-dependency SQLite mode so users can run Erupe without
PostgreSQL. A transparent db.DB wrapper auto-translates PostgreSQL
SQL ($N placeholders, now(), ::casts, ILIKE, public. prefix,
TRUNCATE) for SQLite at runtime — all 28 repo files use the wrapper
with no per-query changes needed.
Setup wizard gains two new steps: quest file detection with download
link, and gameplay presets (solo/small/community/rebalanced). The API
server gets a /dashboard endpoint with auto-refreshing stats.
CI release workflow now builds and pushes Docker images to GHCR
alongside binary artifacts on tag push.
Key changes:
- common/db: DB/Tx wrapper with 6 SQL translation rules
- server/migrations/sqlite: full SQLite schema (0001-0005)
- config: Database.Driver field ("postgres" or "sqlite")
- main.go: SQLite connection with WAL mode, single writer
- server/setup: quest check + preset selection steps
- server/api: /dashboard with live stats
- .github/workflows: Docker in release, deduplicate docker.yml
This commit is contained in:
@@ -3,17 +3,17 @@ package signserver
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
dbutil "erupe-ce/common/db"
|
||||
"github.com/lib/pq"
|
||||
)
|
||||
|
||||
// SignCharacterRepository implements SignCharacterRepo with PostgreSQL.
|
||||
type SignCharacterRepository struct {
|
||||
db *sqlx.DB
|
||||
db *dbutil.DB
|
||||
}
|
||||
|
||||
// NewSignCharacterRepository creates a new SignCharacterRepository.
|
||||
func NewSignCharacterRepository(db *sqlx.DB) *SignCharacterRepository {
|
||||
func NewSignCharacterRepository(db *dbutil.DB) *SignCharacterRepository {
|
||||
return &SignCharacterRepository{db: db}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package signserver
|
||||
|
||||
import "github.com/jmoiron/sqlx"
|
||||
import dbutil "erupe-ce/common/db"
|
||||
|
||||
// SignSessionRepository implements SignSessionRepo with PostgreSQL.
|
||||
type SignSessionRepository struct {
|
||||
db *sqlx.DB
|
||||
db *dbutil.DB
|
||||
}
|
||||
|
||||
// NewSignSessionRepository creates a new SignSessionRepository.
|
||||
func NewSignSessionRepository(db *sqlx.DB) *SignSessionRepository {
|
||||
func NewSignSessionRepository(db *dbutil.DB) *SignSessionRepository {
|
||||
return &SignSessionRepository{db: db}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,16 +3,16 @@ package signserver
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
dbutil "erupe-ce/common/db"
|
||||
)
|
||||
|
||||
// SignUserRepository implements SignUserRepo with PostgreSQL.
|
||||
type SignUserRepository struct {
|
||||
db *sqlx.DB
|
||||
db *dbutil.DB
|
||||
}
|
||||
|
||||
// NewSignUserRepository creates a new SignUserRepository.
|
||||
func NewSignUserRepository(db *sqlx.DB) *SignUserRepository {
|
||||
func NewSignUserRepository(db *dbutil.DB) *SignUserRepository {
|
||||
return &SignUserRepository{db: db}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"net"
|
||||
"sync"
|
||||
|
||||
dbutil "erupe-ce/common/db"
|
||||
cfg "erupe-ce/config"
|
||||
"erupe-ce/network"
|
||||
"github.com/jmoiron/sqlx"
|
||||
@@ -38,9 +39,10 @@ func NewServer(config *Config) *Server {
|
||||
erupeConfig: config.ErupeConfig,
|
||||
}
|
||||
if config.DB != nil {
|
||||
s.userRepo = NewSignUserRepository(config.DB)
|
||||
s.charRepo = NewSignCharacterRepository(config.DB)
|
||||
s.sessionRepo = NewSignSessionRepository(config.DB)
|
||||
wdb := dbutil.Wrap(config.DB)
|
||||
s.userRepo = NewSignUserRepository(wdb)
|
||||
s.charRepo = NewSignCharacterRepository(wdb)
|
||||
s.sessionRepo = NewSignSessionRepository(wdb)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user