adding validated services? patching forcad_local.py
This commit is contained in:
32
OmCTF-2025/services/block_game/backend/db/db.go
Normal file
32
OmCTF-2025/services/block_game/backend/db/db.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"omctf.ru/block-game-backend/codegen/ent"
|
||||
)
|
||||
|
||||
var Client *ent.Client
|
||||
|
||||
func Initialize() {
|
||||
ctx := context.Background()
|
||||
|
||||
var err error
|
||||
Client, err = ent.Open("postgres", "host=postgres port=5432 user=postgres dbname=blockgame password=postgres sslmode=disable")
|
||||
if err != nil {
|
||||
log.Fatalf("failed opening connection to postgres: %v", err)
|
||||
}
|
||||
|
||||
// uncomment to show the queries
|
||||
// Client = Client.Debug()
|
||||
|
||||
// Run the auto migration tool.
|
||||
if err := Client.Schema.Create(ctx); err != nil {
|
||||
log.Fatalf("failed creating schema resources: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func Close() {
|
||||
Client.Close()
|
||||
}
|
||||
Reference in New Issue
Block a user