Refactored Alert schedule (#9514)

* add AlertSchedule model and relationships
change table structure to match the expected layout

* Update maint schedule map ui

* better index name

* Laravel queries
fix some issues with the ui: restricting start incorrectly and loading empty days error

* handle date limiting properly

* Another attempt add schedule constraints

* use Auth

* Update WorldMap widget to use check isUnderMaintenance

* Rename 275.sql to 276.sql

* Rename 276.sql to 277.sql
This commit is contained in:
Tony Murray
2019-01-03 16:42:12 -06:00
committed by Neil Lathwood
parent 0cc599c576
commit f10cbddacc
10 changed files with 249 additions and 141 deletions

7
sql-schema/277.sql Normal file
View File

@@ -0,0 +1,7 @@
ALTER TABLE alert_schedule_items ADD alert_schedulable_type varchar(255) NOT NULL;
UPDATE alert_schedule_items SET alert_schedulable_type = 'device_group' WHERE target LIKE 'g%';
UPDATE alert_schedule_items SET alert_schedulable_type = 'device' WHERE alert_schedulable_type='';
UPDATE alert_schedule_items SET target = SUBSTRING(target, 2) WHERE target LIKE 'g%';
ALTER TABLE alert_schedule_items CHANGE target alert_schedulable_id int(11) unsigned NOT NULL;
ALTER TABLE alert_schedule_items RENAME TO alert_schedulables;
CREATE INDEX `schedulable_morph_index` ON alert_schedulables (alert_schedulable_type, alert_schedulable_id);