mirror of
https://github.com/notherealmarco/WASAPhoto.git
synced 2025-03-13 13:35:23 +01:00
Revert back db tables check
This commit is contained in:
parent
003e66d841
commit
1fc1df577d
2 changed files with 5 additions and 5 deletions
6
.vscode/launch.json
vendored
6
.vscode/launch.json
vendored
|
@ -12,9 +12,9 @@
|
||||||
"mode": "auto",
|
"mode": "auto",
|
||||||
"buildFlags": "-tags webui",
|
"buildFlags": "-tags webui",
|
||||||
"program": "./cmd/webapi",
|
"program": "./cmd/webapi",
|
||||||
"args": [
|
//"args": [
|
||||||
"--db-filename", "/home/marco/wasa/wasadata/wasaphoto.db", "--data-path", "/home/marco/wasa/wasadata/data"
|
// "--db-filename", "/home/marco/wasa/wasadata/wasaphoto.db", "--data-path", "/home/marco/wasa/wasadata/data"
|
||||||
]
|
//]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -98,8 +98,8 @@ func New(db *sql.DB) (AppDatabase, error) {
|
||||||
// Check if tables exist. If not, the database is empty, and we need to create the structure
|
// Check if tables exist. If not, the database is empty, and we need to create the structure
|
||||||
var tableName string
|
var tableName string
|
||||||
//todo: check for all the tables, not just users
|
//todo: check for all the tables, not just users
|
||||||
err := db.QueryRow(`SELECT uid from users LIMIT 1;`).Scan(&tableName)
|
err := db.QueryRow(`SELECT name FROM sqlite_master WHERE type='table' AND name='users';`).Scan(&tableName)
|
||||||
if err != nil {
|
if errors.Is(err, sql.ErrNoRows) {
|
||||||
//fmt.Println("database is empty, creating structure")
|
//fmt.Println("database is empty, creating structure")
|
||||||
sqlStmt := `CREATE TABLE "users" (
|
sqlStmt := `CREATE TABLE "users" (
|
||||||
"uid" TEXT NOT NULL,
|
"uid" TEXT NOT NULL,
|
||||||
|
|
Loading…
Reference in a new issue