1: <?php
2:
3: use Illuminate\Database\Migrations\Migration;
4: use Illuminate\Database\Schema\Blueprint;
5: use Illuminate\Database\Capsule\Manager as Capsule;
6:
7: class CreateTables extends Migration
8: {
9: /**
10: * Run the migrations.
11: *
12: * @return void
13: */
14: public function up()
15: {
16: /*
17: * Attention! 'uri' and 'uid' fields need to be at least 255 length
18: */
19: $sPrefix = Capsule::connection()->getTablePrefix();
20:
21: $sSql = str_replace(
22: "%PREFIX%",
23: $sPrefix,
24: "CREATE TABLE IF NOT EXISTS `%PREFIX%adav_addressbooks` (
25: id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
26: principaluri VARBINARY(255),
27: displayname VARCHAR(255),
28: uri VARBINARY(255),
29: description TEXT,
30: synctoken INT(11) UNSIGNED NOT NULL DEFAULT '1',
31: UNIQUE(principaluri(100), uri(100))
32: ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
33: );
34: Capsule::connection()->statement($sSql);
35:
36: $sSql = str_replace(
37: "%PREFIX%",
38: $sPrefix,
39: "CREATE TABLE IF NOT EXISTS `%PREFIX%adav_addressbookchanges` (
40: id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
41: uri VARBINARY(255) NOT NULL,
42: synctoken INT(11) UNSIGNED NOT NULL,
43: addressbookid INT(11) UNSIGNED NOT NULL,
44: operation TINYINT(1) NOT NULL,
45: INDEX addressbookid_synctoken (addressbookid, synctoken)
46: ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"
47: );
48: Capsule::connection()->statement($sSql);
49:
50: $sSql = str_replace(
51: "%PREFIX%",
52: $sPrefix,
53: "CREATE TABLE IF NOT EXISTS `%PREFIX%adav_cache` (
54: `id` int(11) NOT NULL auto_increment,
55: `user` varchar(255) default NULL,
56: `calendaruri` varchar(255) default NULL,
57: `type` tinyint(4) default NULL,
58: `time` int(11) default NULL,
59: `starttime` int(11) default NULL,
60: `eventid` varchar(45) default NULL,
61: PRIMARY KEY (`id`)
62: ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
63: );
64: Capsule::connection()->statement($sSql);
65:
66: $sSql = str_replace(
67: "%PREFIX%",
68: $sPrefix,
69: "CREATE TABLE IF NOT EXISTS `%PREFIX%adav_calendarinstances` (
70: `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
71: `calendarid` INT(10) UNSIGNED NOT NULL,
72: `principaluri` VARBINARY(100) NULL DEFAULT NULL,
73: `access` TINYINT(1) NOT NULL DEFAULT '1' COMMENT '1 = owner, 2 = read, 3 = readwrite',
74: `displayname` VARCHAR(100) NULL DEFAULT NULL,
75: `uri` VARBINARY(255) NULL DEFAULT NULL,
76: `description` TEXT NULL,
77: `calendarorder` INT(11) UNSIGNED NOT NULL DEFAULT '0',
78: `calendarcolor` VARBINARY(10) NULL DEFAULT NULL,
79: `timezone` TEXT NULL,
80: `transparent` TINYINT(1) NOT NULL DEFAULT '0',
81: `share_href` VARBINARY(100) NULL DEFAULT NULL,
82: `share_displayname` VARCHAR(100) NULL DEFAULT NULL,
83: `share_invitestatus` TINYINT(1) NOT NULL DEFAULT '2' COMMENT '1 = noresponse, 2 = accepted, 3 = declined, 4 = invalid',
84: `public` TINYINT(1) NOT NULL DEFAULT '0',
85: PRIMARY KEY (`id`),
86: UNIQUE INDEX `principaluri` (`principaluri`, `uri`),
87: UNIQUE INDEX `calendarid` (`calendarid`, `principaluri`),
88: UNIQUE INDEX `calendarid_2` (`calendarid`, `share_href`)
89: )ENGINE=InnoDB DEFAULT CHARSET=utf8;"
90: );
91: Capsule::connection()->statement($sSql);
92:
93: $sSql = str_replace(
94: "%PREFIX%",
95: $sPrefix,
96: "CREATE TABLE IF NOT EXISTS `%PREFIX%adav_calendarobjects` (
97: id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
98: calendardata MEDIUMBLOB,
99: uri VARBINARY(255),
100: calendarid INTEGER UNSIGNED NOT NULL,
101: lastmodified INT(11) UNSIGNED,
102: etag VARBINARY(32),
103: size INT(11) UNSIGNED NOT NULL,
104: componenttype VARBINARY(8),
105: firstoccurence INT(11) UNSIGNED,
106: lastoccurence INT(11) UNSIGNED,
107: uid VARBINARY(255),
108: UNIQUE(calendarid, uri)
109: ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
110: );
111: Capsule::connection()->statement($sSql);
112:
113: $sSql = str_replace(
114: "%PREFIX%",
115: $sPrefix,
116: "CREATE TABLE IF NOT EXISTS `%PREFIX%adav_calendars` (
117: `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
118: `synctoken` INT(10) UNSIGNED NOT NULL DEFAULT '1',
119: `components` VARBINARY(21) NULL DEFAULT NULL,
120: PRIMARY KEY (`id`)
121: ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
122: );
123: Capsule::connection()->statement($sSql);
124:
125: $sSql = str_replace(
126: "%PREFIX%",
127: $sPrefix,
128: "CREATE TABLE IF NOT EXISTS `%PREFIX%adav_calendarchanges` (
129: id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
130: uri VARBINARY(255) NOT NULL,
131: synctoken INT(11) UNSIGNED NOT NULL,
132: calendarid INT(11) UNSIGNED NOT NULL,
133: operation TINYINT(1) NOT NULL,
134: INDEX calendarid_synctoken (calendarid, synctoken)
135: ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"
136: );
137: Capsule::connection()->statement($sSql);
138:
139: $sSql = str_replace(
140: "%PREFIX%",
141: $sPrefix,
142: "CREATE TABLE IF NOT EXISTS `%PREFIX%adav_calendarsubscriptions` (
143: id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
144: uri VARBINARY(255) NOT NULL,
145: principaluri VARBINARY(100) NOT NULL,
146: source TEXT,
147: displayname VARCHAR(100),
148: refreshrate VARCHAR(10),
149: calendarorder INT(11) UNSIGNED NOT NULL DEFAULT '0',
150: calendarcolor VARBINARY(10),
151: striptodos TINYINT(1) NULL,
152: stripalarms TINYINT(1) NULL,
153: stripattachments TINYINT(1) NULL,
154: lastmodified INT(11) UNSIGNED,
155: UNIQUE(principaluri, uri)
156: ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"
157: );
158: Capsule::connection()->statement($sSql);
159:
160: $sSql = str_replace(
161: "%PREFIX%",
162: $sPrefix,
163: "CREATE TABLE IF NOT EXISTS `%PREFIX%adav_schedulingobjects` (
164: id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
165: principaluri VARBINARY(255),
166: calendardata MEDIUMBLOB,
167: uri VARBINARY(255),
168: lastmodified INT(11) UNSIGNED,
169: etag VARBINARY(32),
170: size INT(11) UNSIGNED NOT NULL
171: ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"
172: );
173: Capsule::connection()->statement($sSql);
174:
175: $sSql = str_replace(
176: "%PREFIX%",
177: $sPrefix,
178: "CREATE TABLE IF NOT EXISTS `%PREFIX%adav_cards` (
179: id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
180: addressbookid INT(11) UNSIGNED NOT NULL,
181: carddata MEDIUMBLOB,
182: uri VARBINARY(255),
183: lastmodified INT(11) UNSIGNED,
184: etag VARBINARY(32),
185: size INT(11) UNSIGNED NOT NULL
186: ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
187: );
188: Capsule::connection()->statement($sSql);
189:
190: $sSql = str_replace(
191: "%PREFIX%",
192: $sPrefix,
193: "CREATE TABLE IF NOT EXISTS `%PREFIX%adav_groupmembers` (
194: `id` int(11) unsigned NOT NULL auto_increment,
195: `principal_id` int(11) unsigned NOT NULL,
196: `member_id` int(11) unsigned NOT NULL,
197: PRIMARY KEY (`id`),
198: UNIQUE KEY `%PREFIX%ADAV_GROUPMEMBERS_MEMBER_ID_PRINCIPAL_ID_INDEX` (`principal_id`,`member_id`)
199: ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
200: );
201: Capsule::connection()->statement($sSql);
202:
203: $sSql = str_replace(
204: "%PREFIX%",
205: $sPrefix,
206: "CREATE TABLE IF NOT EXISTS `%PREFIX%adav_locks` (
207: id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
208: owner VARCHAR(100),
209: timeout INTEGER UNSIGNED,
210: created INTEGER,
211: token VARBINARY(100),
212: scope TINYINT,
213: depth TINYINT,
214: uri VARBINARY(1000),
215: INDEX(token),
216: INDEX(uri(100))
217: ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
218: );
219: Capsule::connection()->statement($sSql);
220:
221: $sSql = str_replace(
222: "%PREFIX%",
223: $sPrefix,
224: "CREATE TABLE IF NOT EXISTS `%PREFIX%adav_propertystorage` (
225: id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
226: path VARBINARY(1024) NOT NULL,
227: name VARBINARY(100) NOT NULL,
228: valuetype INT UNSIGNED,
229: value MEDIUMBLOB,
230: UNIQUE INDEX path_property (path(600), name(100))
231: ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"
232: );
233: Capsule::connection()->statement($sSql);
234:
235: $sSql = str_replace(
236: "%PREFIX%",
237: $sPrefix,
238: "CREATE TABLE IF NOT EXISTS `%PREFIX%adav_reminders` (
239: `id` int(11) unsigned NOT NULL auto_increment,
240: `user` varchar(100) NOT NULL,
241: `calendaruri` varchar(255) default NULL,
242: `eventid` varchar(255) default NULL,
243: `time` int(11) default NULL,
244: `starttime` int(11) default NULL,
245: `allday` tinyint(1) NOT NULL default '0',
246: PRIMARY KEY (`id`)
247: ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
248: );
249: Capsule::connection()->statement($sSql);
250: }
251:
252: /**
253: * Reverse the migrations.
254: *
255: * @return void
256: */
257: public function down()
258: {
259: Capsule::schema()->dropIfExists('adav_addressbooks');
260: Capsule::schema()->dropIfExists('adav_addressbookchanges');
261: Capsule::schema()->dropIfExists('adav_cache');
262: Capsule::schema()->dropIfExists('adav_calendarinstances');
263: Capsule::schema()->dropIfExists('adav_calendarobjects');
264: Capsule::schema()->dropIfExists('adav_calendars');
265: Capsule::schema()->dropIfExists('adav_calendarchanges');
266: Capsule::schema()->dropIfExists('adav_calendarsubscriptions');
267: Capsule::schema()->dropIfExists('adav_schedulingobjects');
268: Capsule::schema()->dropIfExists('adav_cards');
269: Capsule::schema()->dropIfExists('adav_groupmembers');
270: Capsule::schema()->dropIfExists('adav_locks');
271: Capsule::schema()->dropIfExists('adav_propertystorage');
272: Capsule::schema()->dropIfExists('adav_reminders');
273: }
274: }
275: