cayleygraph / cayleygraph/cayley
ERROR: Cannot create nodes table: quadstore: cannot init; database already exists
- Dominant language
- Go
- Stars
- 15.1k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
**Description**
I use cayley as a lib, postgres as database backend.
here is my code
```
err1 := graph.InitQuadStore(dbName, dbPath, nil)
if err1 != nil {
fmt.Println("fail: ", err1)
if err1 == graph.ErrNotInitialized {
err2 := sql.Init(dbName, dbPath, nil)
if err2 != nil {
fmt.Println("err2:", err1)
return
}
} else if err1 == graph.ErrDatabaseExists {
fmt.Println("database is exist")
}
}
store, err3 := cayley.NewGraph(dbName, dbPath, nil)
if err3 != nil {
fmt.Println("err3:", err3)
return
}
```
it can run without err at first, but get err at second `ERROR: Cannot create nodes table: quadstore: cannot init; database already exists`. Is is normal ?
if I delete the `graph.InitQuadStore` part , just run `cayley.NewGraph`. it get err `pq: relation "nodes" does not exist`
Is that I code wrong? Can someone show me some example, thanks~😂
Contributor guide
Research direction
Start by tracing the initialization flow through graph.InitQuadStore, sql.Init, and cayley.NewGraph for the PostgreSQL backend. Compare the first and second runs to determine which call creates the database and tables, then verify the correct sequence no longer produces the existing-database or missing-nodes-table errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, postgres
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100