diff options
Diffstat (limited to 'data_model/schema.sql')
-rw-r--r-- | data_model/schema.sql | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/data_model/schema.sql b/data_model/schema.sql new file mode 100644 index 0000000..c4a554d --- /dev/null +++ b/data_model/schema.sql @@ -0,0 +1,54 @@ +BEGIN TRANSACTION; +DROP TABLE IF EXISTS "Schedules"; +CREATE TABLE IF NOT EXISTS "Schedules" ( + "id" INTEGER, + "name" TEXT NOT NULL, + PRIMARY KEY("id") +); +DROP TABLE IF EXISTS "Tasks"; +CREATE TABLE IF NOT EXISTS "Tasks" ( + "id" INTEGER, + "name" TEXT NOT NULL, + "description" TEXT, + "frequency" INTEGER NOT NULL, + "estimated_length" INTEGER, + "date_completed" INTEGER, + PRIMARY KEY("id") +); +DROP TABLE IF EXISTS "TimeSlotTasks"; +CREATE TABLE IF NOT EXISTS "TimeSlotTasks" ( + "timeslot_id" INTEGER NOT NULL, + "task_id" INTEGER NOT NULL, + PRIMARY KEY("timeslot_id","task_id"), + FOREIGN KEY("task_id") REFERENCES "Tasks"("id") ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY("timeslot_id") REFERENCES "TimeSlots"("id") ON UPDATE CASCADE ON DELETE CASCADE +); +DROP TABLE IF EXISTS "SubTasks"; +CREATE TABLE IF NOT EXISTS "SubTasks" ( + "id" INTEGER, + "task_id" INTEGER NOT NULL, + "name" TEXT NOT NULL, + "date_completed" INTEGER, + PRIMARY KEY("id"), + FOREIGN KEY("task_id") REFERENCES "Tasks"("id") ON UPDATE CASCADE ON DELETE CASCADE +); +DROP TABLE IF EXISTS "TimeSlots"; +CREATE TABLE IF NOT EXISTS "TimeSlots" ( + "id" INTEGER, + "schedule_id" INTEGER NOT NULL, + "start_time" INTEGER NOT NULL, + "end_time" INTEGER NOT NULL, + "name" TEXT NOT NULL, + "date_completed" INTEGER, + PRIMARY KEY("id"), + FOREIGN KEY("schedule_id") REFERENCES "Schedules"("id") ON UPDATE CASCADE ON DELETE CASCADE +); +DROP TABLE IF EXISTS "Version"; +CREATE TABLE IF NOT EXISTS "Version" ( + "major" INTEGER NOT NULL, + "minor" INTEGER NOT NULL, + "patch" INTEGER NOT NULL +); +INSERT INTO "Schedules" VALUES (1,'default'); +INSERT INTO "Version" VALUES (0,1,0); +COMMIT; |