Browse Source

updated alarms migration

Added foreign key and constraints for event+trigger time uniqueness
main
Stefan Pranger 3 years ago
parent
commit
297c5e13ad
  1. 6
      db/migrations/1624964657_create_alarms.h

6
db/migrations/1624964657_create_alarms.h

@ -10,11 +10,13 @@ namespace db {
// action should be an enum // action should be an enum
m1624964657_create_alarms() : Migration() { m1624964657_create_alarms() : Migration() {
db_builder::Table create_alarms = db_builder::Table::create("alarms" db_builder::Table create_alarms = db_builder::Table::create("alarms"
).integer("id", "PRIMARY KEY"
).integer("eventID", "REFERENCES events(uid)"
).integer("id", "NOT NULL PRIMARY KEY"
).text("description" ).text("description"
).text("action" ).text("action"
).text("absolute_trigger" ).text("absolute_trigger"
).integer("event_id", "NOT NULL"
).fk("event_id", "events", "id", "ON DELETE CASCADE ON UPDATE NO ACTION"
).constraint("event_time_unique", "event_id, absolute_trigger"
).close(); ).close();

Loading…
Cancel
Save