1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 07:12:41 +01:00
phorge-phorge/resources/sql/autopatches/20161003.cal.01.utcepoch.sql

9 lines
265 B
MySQL
Raw Normal View History

Introduce Calendar "UTC Epoch" columns for query windowing Summary: Ref T10747. Currently, Calendar events are mostly epoch-based and cheat a little bit for all-day events. This already felt a little flimsy, and can't reasonably accommodate the full range of `.ics` events, which include "floating" events (e.g., occurs at 3PM regardless of timezone, like "Tea Time"). As a secondary issue, we identify instances of a recurring event by instance number (1, 2, 3, etc.). This can't accommodate the full range of `.ics` events, which include arbitrary additional "RDATE" events (e.g., recurrs every week, and also on these specific extra days). However, we do need to store some epoch information so we can do query windowing: when the user looks at "October 2016", we want to select the smallest number of events that we can from the database initially, before refining them down to generate instances. We can't reasonably query the actual dates no matter how we store them because this depends on computing things like UNTIL, COUNT, initial dates, whether events are recurring or not, timezones, etc. Instead, when we save an event compute the earliest second it occurs on in UTC and the latest second it occurs on in UTC. We can then query for a small superset of possible events in "October 2016" for any viewer pretty easily. Also, start laying the groundwork for using fewer epochs in the rest of the code, and for reducing the role of sequence indexes (I plan to keep some sequences indexes around, probably, since they're nice in the UI, but not all child events will have indexes since there's no index for an RDATE event). This doesn't migrate existing events yet or actually read these new columns -- that will come later once the new code is a little more solid. Test Plan: - Ran `bin/storage upgrade`. - Created a new event. - Saved an existing event. - Viewed database, saw sensible-looking "UTC Epoch" values. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10747 Differential Revision: https://secure.phabricator.com/D16652
2016-10-03 17:32:06 +02:00
ALTER TABLE {$NAMESPACE}_calendar.calendar_event
ADD utcInitialEpoch INT UNSIGNED NOT NULL;
ALTER TABLE {$NAMESPACE}_calendar.calendar_event
ADD utcUntilEpoch INT UNSIGNED;
ALTER TABLE {$NAMESPACE}_calendar.calendar_event
ADD utcInstanceEpoch INT UNSIGNED;