Added dodo.schema and modified Makefile to include db creation

This commit is contained in:
xavi 2024-08-20 21:49:45 -07:00
parent 3a86a83f54
commit 52b70c3df1
2 changed files with 29 additions and 1 deletions

View File

@ -3,6 +3,8 @@
SRC = dodo.c sqlite3.c x_string.c
OBJ = $(SRC:.c=.o)
CONFIG_PATH = $$HOME/.config/dodo
all: dodo
$(OBJ):
@ -10,7 +12,14 @@ $(OBJ):
dodo: $(OBJ)
$(CC) -o $@ $(OBJ)
install: dodo
mkdir -p $(CONFIG_PATH)
sqlite3 $(CONFIG_PATH)/dodo.db < dodo.schema
uninstall:
rm -rf $(CONFIG_PATH)
clean:
rm -f dodo $(OBJ)
.PHONY: clean
.PHONY: all clean install uninstall

19
src/dodo.schema Normal file
View File

@ -0,0 +1,19 @@
CREATE TABLE tasks(
task_id INTEGER PRIMARY KEY,
title TEXT NOT NULL,
status TEXT NOT NULL DEFAULT 'backlog',
due_date DATE,
creation_date DATE DEFAULT (date('now'))
);
CREATE TABLE entries(
entry_id INTEGER PRIMARY KEY,
task_id INTEGER NOT NULL REFERENCES tasks(task_id),
body TEXT NOT NULL,
creation_date DATETIME DEFAULT (datetime('now', 'localtime'))
);
INSERT INTO tasks (title) VALUES ('test1'), ('test2'), ('test3');
INSERT INTO entries (task_id, body) VALUES (1, 'this is an entry for test1'), (2, 'this is an entry for test2'), (3, 'this is an entry for test3');
CREATE VIEW all_info AS SELECT * FROM entries JOIN tasks ON entries.task_id = tasks.task_id;