aboutsummaryrefslogtreecommitdiff
path: root/src/db/init.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/db/init.py')
-rw-r--r--src/db/init.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/db/init.py b/src/db/init.py
index 8fb7098..8292dfc 100644
--- a/src/db/init.py
+++ b/src/db/init.py
@@ -3,14 +3,20 @@ import os.path
import time
def init(path):
+
is_db_new = not os.path.isfile(path)
+
database = sqlite3.connect(path)
+
if is_db_new:
- database.cursor().execute(
+
+ cursor = database.cursor()
+
+ cursor.execute(
" CREATE TABLE IF NOT EXISTS tasks("
" id INTEGER PRIMARY KEY,"
" created_at INTEGER NOT NULL,"
- " modified_at INTEGER NOT NULL,"
+ " updated_at INTEGER NOT NULL,"
" name TEXT NOT NULL,"
" duration INTEGER,"
" tag TEXT,"
@@ -18,5 +24,16 @@ def init(path):
" priority INT,"
" description TEXT"
" )")
+
+ cursor.execute(
+ " CREATE TABLE IF NOT EXISTS tags("
+ " id INTEGER PRIMARY KEY,"
+ " created_at INTEGER NOT NULL,"
+ " updated_at INTEGER NOT NULL,"
+ " name TEXT NOT NULL,"
+ " color TEXT NOT NULL"
+ " )")
+
database.commit()
+
return database