cayleygraph / cayleygraph/cayley

ERROR: Cannot create nodes table: quadstore: cannot init; database already exists

Open
#727 5 comments 0 reactions 0 assignees View on GitHub
question
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.