Move stuff to data folder, so I can just gitignore that entire folder

This commit is contained in:
Quad 2022-04-13 17:24:01 +02:00
parent 88cbeee562
commit 7c484b18d3
2 changed files with 11 additions and 6 deletions

4
.gitignore vendored
View File

@ -4,5 +4,5 @@
# Binary name built by nimble # Binary name built by nimble
nimblog nimblog
# Database # Blog data
blog.db data/*

View File

@ -1,8 +1,9 @@
when isMainModule: when isMainModule:
import tables import tables
import modules/blog import os
import modules/env import modules/[blog, env, db]
import modules/db
let dataDir: string = "data"
let settings = { let settings = {
"debug": boolEnvOrDefault("DEBUG", false), "debug": boolEnvOrDefault("DEBUG", false),
@ -10,10 +11,14 @@ when isMainModule:
}.toTable() }.toTable()
let dbSettings = { let dbSettings = {
"path": "blog.db", "path": dataDir & "/" & "blog.db",
"schema_path": "schema.sql" "schema_path": "schema.sql"
}.toTable() }.toTable()
if not dirExists(dataDir):
echo "Created data directory"
createDir(dataDir)
if not createDb(dbSettings): if not createDb(dbSettings):
echo "Failed to prepare database" echo "Failed to prepare database"
quit(QuitFailure) quit(QuitFailure)