Browse Source

added alarm migration and changes events table

main
Stefan Pranger 3 years ago
parent
commit
bdcd71bbde
  1. 2
      db/Schema.cpp
  2. 15
      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 "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());
}
}

15
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();
}
};

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