[9bbd5ae] | 1 | BEGIN TRANSACTION; |
---|
| 2 | |
---|
| 3 | ALTER TABLE conference RENAME TO conference_old; |
---|
| 4 | ALTER TABLE track RENAME TO track_old; |
---|
| 5 | ALTER TABLE room RENAME TO room_old; |
---|
| 6 | ALTER TABLE person RENAME TO person_old; |
---|
| 7 | ALTER TABLE event RENAME TO event_old; |
---|
| 8 | ALTER TABLE event_person RENAME TO event_person_old; |
---|
| 9 | ALTER TABLE event_room RENAME TO event_room_old; |
---|
| 10 | ALTER TABLE link RENAME TO link_old; |
---|
| 11 | |
---|
| 12 | CREATE TABLE conference ( |
---|
| 13 | id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, |
---|
| 14 | title VARCHAR NOT NULL, |
---|
| 15 | subtitle VARCHAR, |
---|
| 16 | venue VARCHAR, |
---|
| 17 | city VARCHAR, |
---|
[9457aed] | 18 | start INTEGER NOT NULL, -- timezone-less timestamp (Unix Epoch) |
---|
| 19 | end INTEGER NOT NULL, -- timezone-less timestamp (Unix Epoch) |
---|
[9bbd5ae] | 20 | day_change INTEGER, |
---|
| 21 | timeslot_duration INTEGER, |
---|
| 22 | active INTEGER DEFAULT 0, |
---|
| 23 | url VARCHAR |
---|
| 24 | ); |
---|
| 25 | |
---|
| 26 | CREATE TABLE track ( |
---|
| 27 | id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, |
---|
| 28 | xid_conference INTEGER NOT NULL REFERENCES conference(id), |
---|
| 29 | name VARCHAR NOT NULL, |
---|
| 30 | UNIQUE (xid_conference, name) |
---|
| 31 | ); |
---|
| 32 | |
---|
| 33 | CREATE TABLE room ( |
---|
| 34 | id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, |
---|
| 35 | xid_conference INTEGER NOT NULL REFERENCES conference(id), |
---|
| 36 | name VARCHAR NOT NULL, |
---|
| 37 | picture VARCHAR, |
---|
| 38 | UNIQUE (xid_conference, name) |
---|
| 39 | ); |
---|
| 40 | |
---|
| 41 | CREATE TABLE person ( |
---|
| 42 | id INTEGER NOT NULL, |
---|
| 43 | xid_conference INTEGER NOT NULL REFERENCES conference(id), |
---|
| 44 | name VARCHAR NOT NULL, |
---|
| 45 | PRIMARY KEY (id, xid_conference) |
---|
| 46 | ); |
---|
| 47 | |
---|
| 48 | CREATE TABLE event ( |
---|
| 49 | xid_conference INTEGER NOT NULL REFERENCES conference(id), |
---|
| 50 | id INTEGER NOT NULL, |
---|
| 51 | start INTEGER NOT NULL, |
---|
| 52 | duration INTEGER NOT NULL, -- duration of the event in seconds |
---|
| 53 | xid_track INTEGER NOT NULL REFERENCES track(id), |
---|
| 54 | type VARCHAR, |
---|
| 55 | language VARCHAR, |
---|
| 56 | tag VARCHAR, |
---|
| 57 | title VARCHAR NOT NULL, |
---|
| 58 | subtitle VARCHAR, |
---|
| 59 | abstract VARCHAR, |
---|
| 60 | description VARCHAR, |
---|
| 61 | favourite INTEGER DEFAULT 0, |
---|
| 62 | alarm INTEGER DEFAULT 0, |
---|
| 63 | PRIMARY KEY (xid_conference, id) |
---|
| 64 | ); |
---|
| 65 | |
---|
| 66 | CREATE TABLE event_person ( |
---|
| 67 | xid_conference INTEGER NOT NULL, |
---|
| 68 | xid_event INTEGER NOT NULL, |
---|
| 69 | xid_person INTEGER NOT NULL, |
---|
| 70 | UNIQUE (xid_conference, xid_event, xid_person ) ON CONFLICT REPLACE, |
---|
| 71 | FOREIGN KEY(xid_conference) REFERENCES conference(id), |
---|
| 72 | FOREIGN KEY(xid_conference, xid_event) REFERENCES event(xid_conference, id), |
---|
| 73 | FOREIGN KEY(xid_conference, xid_person) REFERENCES person(xid_conference, id) |
---|
| 74 | ); |
---|
| 75 | |
---|
| 76 | CREATE TABLE event_room ( |
---|
| 77 | xid_conference INTEGER NOT NULL, |
---|
| 78 | xid_event INTEGER NOT NULL, |
---|
| 79 | xid_room INTEGER NOT NULL, |
---|
| 80 | UNIQUE (xid_conference, xid_event, xid_room) ON CONFLICT REPLACE, |
---|
| 81 | FOREIGN KEY(xid_conference) REFERENCES conference(id), |
---|
| 82 | FOREIGN KEY(xid_conference, xid_event) REFERENCES event(xid_conference, id), |
---|
| 83 | FOREIGN KEY(xid_conference, xid_room) REFERENCES room(xid_conference, id) |
---|
| 84 | ); |
---|
| 85 | |
---|
| 86 | CREATE TABLE link ( |
---|
| 87 | id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, |
---|
| 88 | xid_conference INTEGER NOT NULL, |
---|
| 89 | xid_event INTEGER NOT NULL, |
---|
| 90 | name VARCHAR, |
---|
| 91 | url VARCHAR NOT NULL, |
---|
| 92 | UNIQUE (xid_conference, xid_event , url) ON CONFLICT REPLACE, |
---|
| 93 | FOREIGN KEY(xid_conference) REFERENCES conference(id), |
---|
| 94 | FOREIGN KEY(xid_conference, xid_event) REFERENCES event(xid_conference, id) |
---|
| 95 | ); |
---|
| 96 | |
---|
| 97 | INSERT INTO conference SELECT id, title, subtitle, venue, city, start, end, day_change, timeslot_duration, active, url FROM conference_old; |
---|
| 98 | INSERT INTO track SELECT * FROM track_old; |
---|
| 99 | INSERT INTO room SELECT * FROM room_old; |
---|
| 100 | INSERT INTO person SELECT * FROM person_old; |
---|
| 101 | INSERT INTO event SELECT * FROM event_old; |
---|
| 102 | INSERT INTO event_person SELECT * FROM event_person_old; |
---|
| 103 | INSERT INTO event_room SELECT * FROM event_room_old; |
---|
| 104 | INSERT INTO link SELECT * FROM link_old; |
---|
| 105 | |
---|
| 106 | DROP TABLE conference_old; |
---|
| 107 | DROP TABLE track_old; |
---|
| 108 | DROP TABLE room_old; |
---|
| 109 | DROP TABLE person_old; |
---|
| 110 | DROP TABLE event_old; |
---|
| 111 | DROP TABLE event_person_old; |
---|
| 112 | DROP TABLE event_room_old; |
---|
| 113 | DROP TABLE link_old; |
---|
| 114 | |
---|
| 115 | PRAGMA user_version=1; |
---|
| 116 | |
---|
| 117 | COMMIT; |
---|
| 118 | |
---|