Mercurial > hg > rc1
comparison plugins/calendar/drivers/database/SQL/sqlite/2015022700.sql @ 3:f6fe4b6ae66a
calendar plugin nearly as distributed
| author | Charlie Root |
|---|---|
| date | Sat, 13 Jan 2018 08:56:12 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 2:c828b0fd4a6e | 3:f6fe4b6ae66a |
|---|---|
| 1 -- ALTER TABLE `events` ADD `instance` varchar(16) NOT NULL DEFAULT '' AFTER `uid`; | |
| 2 -- ALTER TABLE `events` ADD `isexception` tinyint(3) NOT NULL DEFAULT '0' AFTER `instance`; | |
| 3 -- ALTER TABLE `events` CHANGE `alarms` `alarms` TEXT NULL DEFAULT NULL; | |
| 4 | |
| 5 CREATE TABLE temp_events ( | |
| 6 event_id integer NOT NULL PRIMARY KEY, | |
| 7 calendar_id integer NOT NULL default '0', | |
| 8 recurrence_id integer NOT NULL default '0', | |
| 9 uid varchar(255) NOT NULL default '', | |
| 10 created datetime NOT NULL default '1000-01-01 00:00:00', | |
| 11 changed datetime NOT NULL default '1000-01-01 00:00:00', | |
| 12 sequence integer NOT NULL default '0', | |
| 13 start datetime NOT NULL default '1000-01-01 00:00:00', | |
| 14 end datetime NOT NULL default '1000-01-01 00:00:00', | |
| 15 recurrence varchar(255) default NULL, | |
| 16 title varchar(255) NOT NULL, | |
| 17 description text NOT NULL, | |
| 18 location varchar(255) NOT NULL default '', | |
| 19 categories varchar(255) NOT NULL default '', | |
| 20 url varchar(255) NOT NULL default '', | |
| 21 all_day tinyint(1) NOT NULL default '0', | |
| 22 free_busy tinyint(1) NOT NULL default '0', | |
| 23 priority tinyint(1) NOT NULL default '0', | |
| 24 sensitivity tinyint(1) NOT NULL default '0', | |
| 25 status varchar(32) NOT NULL default '', | |
| 26 alarms varchar(255) default NULL, | |
| 27 attendees text default NULL, | |
| 28 notifyat datetime default NULL | |
| 29 ); | |
| 30 | |
| 31 INSERT INTO temp_events (event_id, calendar_id, recurrence_id, uid, created, changed, sequence, start, end, recurrence, title, description, location, categories, url, all_day, free_busy, priority, sensitivity, alarms, attendees, notifyat) | |
| 32 SELECT event_id, calendar_id, recurrence_id, uid, created, changed, sequence, start, end, recurrence, title, description, location, categories, url, all_day, free_busy, priority, sensitivity, alarms, attendees, notifyat | |
| 33 FROM events; | |
| 34 | |
| 35 DROP TABLE events; | |
| 36 | |
| 37 CREATE TABLE events ( | |
| 38 event_id integer NOT NULL PRIMARY KEY, | |
| 39 calendar_id integer NOT NULL default '0', | |
| 40 recurrence_id integer NOT NULL default '0', | |
| 41 uid varchar(255) NOT NULL default '', | |
| 42 instance varchar(16) NOT NULL default '', | |
| 43 isexception tinyint(1) NOT NULL default '0', | |
| 44 created datetime NOT NULL default '1000-01-01 00:00:00', | |
| 45 changed datetime NOT NULL default '1000-01-01 00:00:00', | |
| 46 sequence integer NOT NULL default '0', | |
| 47 start datetime NOT NULL default '1000-01-01 00:00:00', | |
| 48 end datetime NOT NULL default '1000-01-01 00:00:00', | |
| 49 recurrence varchar(255) default NULL, | |
| 50 title varchar(255) NOT NULL, | |
| 51 description text NOT NULL, | |
| 52 location varchar(255) NOT NULL default '', | |
| 53 categories varchar(255) NOT NULL default '', | |
| 54 url varchar(255) NOT NULL default '', | |
| 55 all_day tinyint(1) NOT NULL default '0', | |
| 56 free_busy tinyint(1) NOT NULL default '0', | |
| 57 priority tinyint(1) NOT NULL default '0', | |
| 58 sensitivity tinyint(1) NOT NULL default '0', | |
| 59 status varchar(32) NOT NULL default '', | |
| 60 alarms text default NULL, | |
| 61 attendees text default NULL, | |
| 62 notifyat datetime default NULL, | |
| 63 CONSTRAINT fk_events_calendar_id FOREIGN KEY (calendar_id) | |
| 64 REFERENCES calendars(calendar_id) | |
| 65 ); | |
| 66 | |
| 67 INSERT INTO events (event_id, calendar_id, recurrence_id, uid, created, changed, sequence, start, end, recurrence, title, description, location, categories, url, all_day, free_busy, priority, sensitivity, alarms, attendees, notifyat) | |
| 68 SELECT event_id, calendar_id, recurrence_id, uid, created, changed, sequence, start, end, recurrence, title, description, location, categories, url, all_day, free_busy, priority, sensitivity, alarms, attendees, notifyat | |
| 69 FROM temp_events; | |
| 70 | |
| 71 DROP TABLE temp_events; | |
| 72 | |
| 73 -- Derrive instance columns from start date/time | |
| 74 | |
| 75 UPDATE events SET instance = strftime('%Y%m%d', start) | |
| 76 WHERE recurrence_id != 0 AND instance = '' AND all_day = 1; | |
| 77 | |
| 78 UPDATE events SET instance = strftime('%Y%m%dT%H%M%S', start) | |
| 79 WHERE recurrence_id != 0 AND instance = '' AND all_day = 0; |
