Browse Source

added alarm migration and changes events table

main
Stefan Pranger 3 years ago
parent
commit
bdcd71bbde
  1. 2
      db/Schema.cpp
  2. 11
      db/migrations/1624829187_create_events.h
  3. 25
      db/migrations/1624964657_create_alarms.h

2
db/Schema.cpp

@ -2,6 +2,7 @@
#include <io/debug.h> #include <io/debug.h>
#include "migrations/1624829187_create_events.h" #include "migrations/1624829187_create_events.h"
#include "migrations/1624964657_create_alarms.h"
namespace db { namespace db {
namespace db_builder = db::migrations::builder; namespace db_builder = db::migrations::builder;
@ -84,5 +85,6 @@ namespace db {
void Schema::assemble_migrations() { void Schema::assemble_migrations() {
migrations.emplace(1624829187, new db::migrations::m1624829187_create_events()); migrations.emplace(1624829187, new db::migrations::m1624829187_create_events());
migrations.emplace(1624964657, new db::migrations::m1624964657_create_alarms());
} }
} }

11
db/migrations/1624829187_create_events.h

@ -7,13 +7,12 @@ namespace db {
class m1624829187_create_events : public Migration { class m1624829187_create_events : public Migration {
public: public:
m1624829187_create_events() : Migration() { m1624829187_create_events() : Migration() {
db_builder::Table create_events = db_builder::Table::create("event"
db_builder::Table create_events = db_builder::Table::create("events"
).integer("uid", "PRIMARY KEY" ).integer("uid", "PRIMARY KEY"
).integer("year", "NOT NULL"
).integer("month", "NOT NULL"
).integer("day", "NOT NULL"
).integer("hour", "NOT NULL"
).integer("minute", "NOT NULL"
).text("summary", "NOT NULL"
).text("dtstart", "NOT NULL"
).text("dtend", "NOT NULL"
).text("location"
).close(); ).close();
m_statement = create_events.str(); m_statement = create_events.str();
} }

25
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();
}
};
}
}
Loading…
Cancel
Save