[feature] migrate to monorepo
This commit is contained in:
commit
05ddc1f783
267 changed files with 75165 additions and 0 deletions
31
backend/internal/server/ent.go
Normal file
31
backend/internal/server/ent.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"github.com/rs/zerolog/log"
|
||||
"tss-rocks-be/ent"
|
||||
"tss-rocks-be/internal/config"
|
||||
)
|
||||
|
||||
// NewEntClient creates a new ent client
|
||||
func NewEntClient(cfg *config.Config) *ent.Client {
|
||||
// TODO: Implement database connection based on config
|
||||
// For now, we'll use SQLite for development
|
||||
db, err := sql.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1")
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Failed to connect to database")
|
||||
}
|
||||
|
||||
// Create ent client
|
||||
client := ent.NewClient(ent.Driver(db))
|
||||
|
||||
// Run the auto migration tool
|
||||
if err := client.Schema.Create(context.Background()); err != nil {
|
||||
log.Fatal().Err(err).Msg("Failed to create schema resources")
|
||||
}
|
||||
|
||||
return client
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue