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;