From bdcd71bbde5b42390fb61be68d6b2833d1a5b84d Mon Sep 17 00:00:00 2001 From: Stefan Pranger Date: Tue, 29 Jun 2021 14:13:18 +0200 Subject: [PATCH] added alarm migration and changes events table --- db/Schema.cpp | 2 ++ db/migrations/1624829187_create_events.h | 15 +++++++------- db/migrations/1624964657_create_alarms.h | 25 ++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 db/migrations/1624964657_create_alarms.h diff --git a/db/Schema.cpp b/db/Schema.cpp index eaf75cb..20b2efb 100644 --- a/db/Schema.cpp +++ b/db/Schema.cpp @@ -2,6 +2,7 @@ #include #include "migrations/1624829187_create_events.h" +#include "migrations/1624964657_create_alarms.h" namespace db { namespace db_builder = db::migrations::builder; @@ -84,5 +85,6 @@ namespace db { void Schema::assemble_migrations() { migrations.emplace(1624829187, new db::migrations::m1624829187_create_events()); + migrations.emplace(1624964657, new db::migrations::m1624964657_create_alarms()); } } diff --git a/db/migrations/1624829187_create_events.h b/db/migrations/1624829187_create_events.h index a354eeb..35bde41 100644 --- a/db/migrations/1624829187_create_events.h +++ b/db/migrations/1624829187_create_events.h @@ -7,14 +7,13 @@ namespace db { class m1624829187_create_events : public Migration { public: m1624829187_create_events() : Migration() { - db_builder::Table create_events = db_builder::Table::create("event" - ).integer("uid", "PRIMARY KEY" - ).integer("year", "NOT NULL" - ).integer("month", "NOT NULL" - ).integer("day", "NOT NULL" - ).integer("hour", "NOT NULL" - ).integer("minute", "NOT NULL" - ).close(); + db_builder::Table create_events = db_builder::Table::create("events" + ).integer("uid", "PRIMARY KEY" + ).text("summary", "NOT NULL" + ).text("dtstart", "NOT NULL" + ).text("dtend", "NOT NULL" + ).text("location" + ).close(); m_statement = create_events.str(); } }; diff --git a/db/migrations/1624964657_create_alarms.h b/db/migrations/1624964657_create_alarms.h new file mode 100644 index 0000000..89b9b70 --- /dev/null +++ b/db/migrations/1624964657_create_alarms.h @@ -0,0 +1,25 @@ +#pragma once + +namespace db { + namespace migrations { + namespace db_builder = db::migrations::builder; + + class m1624964657_create_alarms : public Migration { + public: + //TODO https://techsparx.com/software-development/sqlite3/mysql-style-enum.html + // action should be an enum + m1624964657_create_alarms() : Migration() { + db_builder::Table create_alarms = db_builder::Table::create("alarms" + ).integer("id", "PRIMARY KEY" + ).integer("eventID", "REFERENCES events(uid)" + ).text("description" + ).text("action" + ).text("absolute_trigger" + ).close(); + + + m_statement = create_alarms.str(); + } + }; + } +}