mirror of
https://github.com/notherealmarco/WASAPhoto.git
synced 2025-05-05 12:22:35 +02:00
Fix data directory not creating on first run
This commit is contained in:
parent
ec0b06affc
commit
7543fd36e0
3 changed files with 16 additions and 7 deletions
|
@ -98,8 +98,9 @@ func New(db *sql.DB) (AppDatabase, error) {
|
|||
// Check if tables exist. If not, the database is empty, and we need to create the structure
|
||||
var tableName string
|
||||
//todo: check for all the tables, not just users
|
||||
err := db.QueryRow(`SELECT name FROM sqlite_master WHERE type='table' AND name='users';`).Scan(&tableName)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
err := db.QueryRow(`SELECT uid from users LIMIT 1;`).Scan(&tableName)
|
||||
if err != nil {
|
||||
//fmt.Println("database is empty, creating structure")
|
||||
sqlStmt := `CREATE TABLE "users" (
|
||||
"uid" TEXT NOT NULL,
|
||||
"name" TEXT NOT NULL UNIQUE,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue