rework to lighten the main, refactor wrappers. Rehandle csrf and pull config items.
This commit is contained in:
@@ -4,10 +4,15 @@ import (
|
||||
"database/sql"
|
||||
"log"
|
||||
|
||||
"synlotto-website/config"
|
||||
"synlotto-website/logging"
|
||||
|
||||
_ "modernc.org/sqlite"
|
||||
)
|
||||
|
||||
func InitDB(filepath string) *sql.DB {
|
||||
var err error
|
||||
cfg := config.Get()
|
||||
db, err := sql.Open("sqlite", filepath)
|
||||
if err != nil {
|
||||
log.Fatal("❌ Failed to open DB:", err)
|
||||
@@ -30,6 +35,10 @@ func InitDB(filepath string) *sql.DB {
|
||||
SchemaSyndicateInvites,
|
||||
SchemaSyndicateInviteTokens,
|
||||
}
|
||||
if cfg == nil {
|
||||
logging.Error("❌ config is nil — did config.Init() run before InitDB?")
|
||||
panic("config not ready")
|
||||
}
|
||||
|
||||
for _, stmt := range schemas {
|
||||
if _, err := db.Exec(stmt); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user