diff --git a/src/Makefile b/src/Makefile index eb6fd8d..c1cf699 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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 diff --git a/src/dodo.schema b/src/dodo.schema new file mode 100644 index 0000000..395c7ac --- /dev/null +++ b/src/dodo.schema @@ -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;