Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 1 | # Copyright 2016 The Chromium Authors |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 4 | |
| 5 | This file contains a log of ALTER TABLE statements that need to be executed |
| 6 | to bring a Monorail SQL database up to the current schema. |
| 7 | |
| 8 | ================================================================ |
| 9 | 2012-05-24: Added more Project fields. |
| 10 | |
| 11 | ALTER TABLE Project ADD COLUMN read_only_reason VARCHAR(80); |
| 12 | ALTER TABLE Project ADD COLUMN issue_notify_address VARCHAR(80); |
| 13 | ALTER TABLE Project ADD COLUMN attachment_bytes_used INT DEFAULT 0; |
| 14 | ALTER TABLE Project ADD COLUMN attachment_quota INT DEFAULT 52428800; |
| 15 | ALTER TABLE Project ADD COLUMN moved_to VARCHAR(250); |
| 16 | ALTER TABLE Project ADD COLUMN process_inbound_email BOOLEAN DEFAULT FALSE; |
| 17 | |
| 18 | ================================================================ |
| 19 | 2012-06-01: Added inbound_message for issue comments |
| 20 | |
| 21 | ALTER TABLE Comment ADD COLUMN inbound_message TEXT; |
| 22 | |
| 23 | |
| 24 | ================================================================ |
| 25 | 2012-06-05: Removed send_notifications_from_user because Monorail will |
| 26 | not offer that feature any time soon. |
| 27 | |
| 28 | ALTER TABLE ProjectIssueConfig DROP COLUMN send_notifications_from_user; |
| 29 | |
| 30 | |
| 31 | ================================================================ |
| 32 | 2012-06-05: Add initial subscription options. |
| 33 | |
| 34 | ALTER TABLE User2SavedQuery ADD COLUMN subscription_mode |
| 35 | ENUM ('noemail', 'immediate') DEFAULT 'noemail' NOT NULL; |
| 36 | |
| 37 | |
| 38 | ================================================================ |
| 39 | 2012-07-02: Revised project states and added state_reason and delete_time |
| 40 | |
| 41 | ALTER TABLE Project MODIFY COLUMN state ENUM ('live', 'archived', 'deletable') |
| 42 | NOT NULL; |
| 43 | |
| 44 | ALTER TABLE Project ADD COLUMN state_reason VARCHAR(80); |
| 45 | ALTER TABLE Project ADD COLUMN delete_time INT; |
| 46 | |
| 47 | |
| 48 | ================================================================ |
| 49 | 2012-07-05: Added action limits and dismissed cues |
| 50 | |
| 51 | CREATE TABLE ActionLimit ( |
| 52 | user_id INT NOT NULL AUTO_INCREMENT, |
| 53 | action_kind ENUM ( |
| 54 | 'project_creation', 'issue_comment', 'issue_attachment', |
| 55 | 'issue_bulk_edit'), |
| 56 | recent_count INT, |
| 57 | reset_timestamp INT, |
| 58 | lifetime_count INT, |
| 59 | lifetime_limit INT, |
| 60 | |
| 61 | PRIMARY KEY (user_id, action_kind) |
| 62 | ) ENGINE=INNODB; |
| 63 | |
| 64 | |
| 65 | CREATE TABLE DismissedCues ( |
| 66 | user_id INT NOT NULL AUTO_INCREMENT, |
| 67 | cue VARCHAR(40), -- names of the cue cards that the user has dismissed. |
| 68 | |
| 69 | INDEX (user_id) |
| 70 | ) ENGINE=INNODB; |
| 71 | |
| 72 | |
| 73 | ALTER TABLE User ADD COLUMN ignore_action_limits BOOLEAN DEFAULT FALSE; |
| 74 | |
| 75 | ================================================================ |
| 76 | 2012-07-11: No longer using Counter table. |
| 77 | |
| 78 | DROP TABLE Counter; |
| 79 | |
| 80 | ================================================================ |
| 81 | 2012-09-06: Drop AttachmentContent, put blobkey in Attachment |
| 82 | and drop some redundant columns. |
| 83 | |
| 84 | Note: This loses attachment data that might currently be in your |
| 85 | instance. Good thing these schema refinements are getting done |
| 86 | before launch. |
| 87 | |
| 88 | ALTER TABLE Attachment DROP COLUMN attachment_id; |
| 89 | ALTER TABLE Attachment DROP COLUMN comment_created; |
| 90 | ALTER TABLE Attachment ADD COLUMN blobkey VARCHAR(1024) NOT NULL; |
| 91 | |
| 92 | DROP TABLE AttachmentContent; |
| 93 | |
| 94 | ALTER TABLE IssueUpdate DROP COLUMN comment_created; |
| 95 | |
| 96 | |
| 97 | ================================================================ |
| 98 | 2012-11-01: Add Components to IssueUpdate enum. |
| 99 | |
| 100 | alter table IssueUpdate modify field ENUM ('summary', 'status', 'owner', |
| 101 | 'cc', 'labels', 'blockedon', 'blocking', 'mergedinto', 'project', |
| 102 | 'components') NOT NULL; |
| 103 | |
| 104 | |
| 105 | ================================================================ |
| 106 | 2012-12-10: Add template admins and field admins |
| 107 | |
| 108 | |
| 109 | CREATE TABLE FieldDef2Admin ( |
| 110 | field_id INT NOT NULL, |
| 111 | admin_id INT NOT NULL, |
| 112 | |
| 113 | PRIMARY KEY (field_id, admin_id), |
| 114 | FOREIGN KEY (field_id) REFERENCES FieldDef(id), |
| 115 | FOREIGN KEY (admin_id) REFERENCES User(user_id) |
| 116 | ) ENGINE=INNODB; |
| 117 | |
| 118 | CREATE TABLE Template2Admin ( |
| 119 | template_id INT NOT NULL, |
| 120 | admin_id INT NOT NULL, |
| 121 | |
| 122 | PRIMARY KEY (template_id, admin_id), |
| 123 | FOREIGN KEY (template_id) REFERENCES Template(id), |
| 124 | FOREIGN KEY (admin_id) REFERENCES User(user_id) |
| 125 | ) ENGINE=INNODB; |
| 126 | |
| 127 | |
| 128 | ================================================================ |
| 129 | 2012-12-14: Add a table of custom field values |
| 130 | |
| 131 | ALTER TABLE FieldDef MODIFY field_type ENUM ( |
| 132 | 'enum_type', 'int_type', 'str_type', 'user_type') NOT NULL; |
| 133 | |
| 134 | CREATE TABLE Issue2FieldValue ( |
| 135 | iid INT NOT NULL, |
| 136 | field_id INT NOT NULL, |
| 137 | |
| 138 | int_value INT, |
| 139 | str_value VARCHAR(1024), |
| 140 | user_id INT, |
| 141 | |
| 142 | derived BOOLEAN DEFAULT FALSE, |
| 143 | |
| 144 | INDEX (iid, field_id), |
| 145 | INDEX (field_id, int_value), |
| 146 | INDEX (field_id, str_value), |
| 147 | INDEX (field_id, user_id), |
| 148 | |
| 149 | FOREIGN KEY (iid) REFERENCES Issue(id), |
| 150 | -- FOREIGN KEY (field_id) REFERENCES FieldDef(id), |
| 151 | FOREIGN KEY (user_id) REFERENCES User(user_id) |
| 152 | ) ENGINE=INNODB; |
| 153 | |
| 154 | |
| 155 | ================================================================ |
| 156 | 2012-12-18: persistence for update objects on custom fields |
| 157 | |
| 158 | ALTER TABLE IssueUpdate MODIFY field ENUM ( |
| 159 | 'summary', 'status', 'owner', 'cc', 'labels', 'blockedon', 'blocking', 'mergedinto', |
| 160 | 'project', 'components', 'custom' ) NOT NULL; |
| 161 | |
| 162 | ALTER TABLE IssueUpdate ADD custom_field_name VARCHAR(255); |
| 163 | |
| 164 | |
| 165 | ================================================================ |
| 166 | 2012-12-27: Rename component owner to component admin |
| 167 | |
| 168 | DROP TABLE Component2Owner; |
| 169 | |
| 170 | CREATE TABLE Component2Admin ( |
| 171 | component_id SMALLINT UNSIGNED NOT NULL, |
| 172 | admin_id INT NOT NULL, |
| 173 | |
| 174 | PRIMARY KEY (component_id, admin_id), |
| 175 | |
| 176 | FOREIGN KEY (component_id) REFERENCES ComponentDef(id), |
| 177 | FOREIGN KEY (admin_id) REFERENCES User(user_id) |
| 178 | ) ENGINE=INNODB; |
| 179 | |
| 180 | |
| 181 | ================================================================ |
| 182 | 2013-01-20: add field applicability predicate |
| 183 | |
| 184 | ALTER TABLE FieldDef ADD applicable_type VARCHAR(80); |
| 185 | ALTER TABLE FieldDef ADD applicable_predicate TEXT; |
| 186 | |
| 187 | ================================================================ |
| 188 | 2013-01-25: add field validation details |
| 189 | |
| 190 | ALTER TABLE FieldDef ADD max_value INT; |
| 191 | ALTER TABLE FieldDef ADD min_value INT; |
| 192 | ALTER TABLE FieldDef ADD regex VARCHAR(80); |
| 193 | ALTER TABLE FieldDef ADD needs_member BOOLEAN; |
| 194 | ALTER TABLE FieldDef ADD needs_perm VARCHAR(80); |
| 195 | |
| 196 | |
| 197 | ================================================================ |
| 198 | 2013-02-11: add grant and notify to user-valued fields |
| 199 | |
| 200 | ALTER TABLE FieldDef ADD grants_perm VARCHAR(80); |
| 201 | ALTER TABLE FieldDef ADD notify_on ENUM ('never', 'any_comment') DEFAULT 'never' NOT NULL; |
| 202 | |
| 203 | |
| 204 | ================================================================ |
| 205 | 2013-03-17: Add Template2FieldValue |
| 206 | |
| 207 | CREATE TABLE Template2FieldValue ( |
| 208 | template_id INT NOT NULL, |
| 209 | field_id INT NOT NULL, |
| 210 | |
| 211 | int_value INT, |
| 212 | str_value VARCHAR(1024), |
| 213 | user_id INT, |
| 214 | |
| 215 | INDEX (template_id, field_id), |
| 216 | |
| 217 | FOREIGN KEY (template_id) REFERENCES Template(id), |
| 218 | -- FOREIGN KEY (field_id) REFERENCES FieldDef(id), |
| 219 | FOREIGN KEY (user_id) REFERENCES User(user_id) |
| 220 | ) ENGINE=INNODB; |
| 221 | |
| 222 | |
| 223 | ================================================================ |
| 224 | 2013-05-08: eliminated same_org_only |
| 225 | |
| 226 | -- This needs to be done on all shards. |
| 227 | UPDATE Project SET access = 'members_only' WHERE access = 'same_org_only'; |
| 228 | ALTER TABLE Project MODIFY COLUMN access ENUM ('anyone', 'members_only'); |
| 229 | |
| 230 | ================================================================ |
| 231 | 2013-05-08: implemented recent activity timestamp |
| 232 | |
| 233 | -- This needs to be done on all shards. |
| 234 | ALTER TABLE Project ADD recent_activity_timestamp INT; |
| 235 | |
| 236 | ================================================================ |
| 237 | 2013-07-01: use BIGINT for Invalidate timesteps |
| 238 | |
| 239 | ALTER TABLE Invalidate MODIFY COLUMN timestep BIGINT NOT NULL AUTO_INCREMENT; |
| 240 | |
| 241 | |
| 242 | ================================================================ |
| 243 | 2013-07-23: renamed to avoid "participant" |
| 244 | |
| 245 | RENAME TABLE ParticipantDuty TO MemberDuty; |
| 246 | RENAME TABLE ParticipantNotes TO MemberNotes; |
| 247 | |
| 248 | ================================================================ |
| 249 | 2013-08-22: renamed issue_id to local_id |
| 250 | |
| 251 | -- On primary and all shards |
| 252 | ALTER TABLE Issue CHANGE issue_id local_id INT NOT NULL; |
| 253 | |
| 254 | -- On primary only |
| 255 | ALTER TABLE IssueFormerLocations CHANGE issue_id local_id INT NOT NULL; |
| 256 | |
| 257 | ================================================================ |
| 258 | 2013-08-24: renamed iid to issue_id |
| 259 | |
| 260 | -- On primary and all shards |
| 261 | |
| 262 | ALTER TABLE IssueSummary DROP FOREIGN KEY IssueSummary_ibfk_1; |
| 263 | ALTER TABLE IssueSummary CHANGE iid issue_id INT NOT NULL; |
| 264 | ALTER TABLE IssueSummary ADD FOREIGN KEY (issue_id) REFERENCES Issue(id); |
| 265 | |
| 266 | ALTER TABLE Issue2Label DROP FOREIGN KEY Issue2Label_ibfk_1; |
| 267 | ALTER TABLE Issue2Label CHANGE iid issue_id INT NOT NULL; |
| 268 | ALTER TABLE Issue2Label ADD FOREIGN KEY (issue_id) REFERENCES Issue(id); |
| 269 | |
| 270 | ALTER TABLE Issue2Component DROP FOREIGN KEY Issue2Component_ibfk_1; |
| 271 | ALTER TABLE Issue2Component CHANGE iid issue_id INT NOT NULL; |
| 272 | ALTER TABLE Issue2Component ADD FOREIGN KEY (issue_id) REFERENCES Issue(id); |
| 273 | |
| 274 | ALTER TABLE Issue2Cc DROP FOREIGN KEY Issue2Cc_ibfk_1; |
| 275 | ALTER TABLE Issue2Cc CHANGE iid issue_id INT NOT NULL; |
| 276 | ALTER TABLE Issue2Cc ADD FOREIGN KEY (issue_id) REFERENCES Issue(id); |
| 277 | |
| 278 | ALTER TABLE Issue2Notify DROP FOREIGN KEY Issue2Notify_ibfk_1; |
| 279 | ALTER TABLE Issue2Notify CHANGE iid issue_id INT NOT NULL; |
| 280 | ALTER TABLE Issue2Notify ADD FOREIGN KEY (issue_id) REFERENCES Issue(id); |
| 281 | |
| 282 | ALTER TABLE IssueStar DROP FOREIGN KEY IssueStar_ibfk_1; |
| 283 | ALTER TABLE IssueStar CHANGE iid issue_id INT NOT NULL; |
| 284 | ALTER TABLE IssueStar ADD FOREIGN KEY (issue_id) REFERENCES Issue(id); |
| 285 | |
| 286 | ALTER TABLE IssueRelation DROP FOREIGN KEY IssueRelation_ibfk_1; |
| 287 | ALTER TABLE IssueRelation CHANGE iid issue_id INT NOT NULL; |
| 288 | ALTER TABLE IssueRelation ADD FOREIGN KEY (issue_id) REFERENCES Issue(id); |
| 289 | |
| 290 | ALTER TABLE IssueRelation CHANGE dst_iid dst_issue_id INT NOT NULL; |
| 291 | |
| 292 | ALTER TABLE Issue2FieldValue DROP FOREIGN KEY Issue2FieldValue_ibfk_1; |
| 293 | ALTER TABLE Issue2FieldValue CHANGE iid issue_id INT NOT NULL; |
| 294 | ALTER TABLE Issue2FieldValue ADD FOREIGN KEY (issue_id) REFERENCES Issue(id); |
| 295 | |
| 296 | -- On primary only |
| 297 | ALTER TABLE Comment DROP FOREIGN KEY Comment_ibfk_2; |
| 298 | ALTER TABLE Comment CHANGE iid issue_id INT NOT NULL; |
| 299 | ALTER TABLE Comment ADD FOREIGN KEY (issue_id) REFERENCES Issue(id); |
| 300 | |
| 301 | ALTER TABLE Attachment DROP FOREIGN KEY Attachment_ibfk_1; |
| 302 | ALTER TABLE Attachment CHANGE iid issue_id INT NOT NULL; |
| 303 | ALTER TABLE Attachment ADD FOREIGN KEY (issue_id) REFERENCES Issue(id); |
| 304 | |
| 305 | ALTER TABLE IssueUpdate DROP FOREIGN KEY IssueUpdate_ibfk_1; |
| 306 | ALTER TABLE IssueUpdate CHANGE iid issue_id INT NOT NULL; |
| 307 | ALTER TABLE IssueUpdate ADD FOREIGN KEY (issue_id) REFERENCES Issue(id); |
| 308 | |
| 309 | -- I was missing a foreign key constraint here. Adding now. |
| 310 | ALTER TABLE IssueFormerLocations CHANGE iid issue_id INT NOT NULL; |
| 311 | ALTER TABLE IssueFormerLocations ADD FOREIGN KEY (issue_id) REFERENCES Issue(id); |
| 312 | |
| 313 | -- I was missing a foreign key constraint here. Adding now. |
| 314 | ALTER TABLE ReindexQueue CHANGE iid issue_id INT NOT NULL; |
| 315 | ALTER TABLE ReindexQueue ADD FOREIGN KEY (issue_id) REFERENCES Issue(id); |
| 316 | |
| 317 | |
| 318 | ================================================================ |
| 319 | 2013-08-30: added per-project email sending flag |
| 320 | |
| 321 | -- On primary and all shards |
| 322 | ALTER TABLE Project ADD COLUMN deliver_outbound_email BOOLEAN DEFAULT FALSE; |
| 323 | |
| 324 | |
| 325 | ================================================================ |
| 326 | 2013-10-30: renamed prompts to templates |
| 327 | |
| 328 | ALTER TABLE ProjectIssueConfig |
| 329 | CHANGE default_prompt_for_developers default_template_for_developers INT NOT NULL; |
| 330 | |
| 331 | ALTER TABLE ProjectIssueConfig |
| 332 | CHANGE default_prompt_for_users default_template_for_users INT NOT NULL; |
| 333 | |
| 334 | ALTER TABLE Template |
| 335 | CHANGE prompt_name name VARCHAR(255) NOT NULL, |
| 336 | CHANGE prompt_text content TEXT, |
| 337 | CHANGE prompt_summary summary TEXT, |
| 338 | CHANGE prompt_summary_must_be_edited summary_must_be_edited BOOLEAN, |
| 339 | CHANGE prompt_owner_id owner_id INT, |
| 340 | CHANGE prompt_status status VARCHAR(255), |
| 341 | CHANGE prompt_members_only members_only BOOLEAN; |
| 342 | |
| 343 | |
| 344 | ================================================================ |
| 345 | 2013-11-18: add LocalIDCounter to primary DB only, and fill in values. |
| 346 | |
| 347 | CREATE TABLE LocalIDCounter ( |
| 348 | project_id SMALLINT UNSIGNED NOT NULL, |
| 349 | used_local_id INT NOT NULL, |
| 350 | |
| 351 | PRIMARY KEY (project_id), |
| 352 | FOREIGN KEY (project_id) REFERENCES Project(project_id) |
| 353 | ) ENGINE=INNODB; |
| 354 | |
| 355 | |
| 356 | -- Note: this ignores former issue locations, so it can only be run |
| 357 | -- now, before the "move issue" feature is offered. |
| 358 | REPLACE INTO LocalIDCounter |
| 359 | SELECT project_id, MAX(local_id) |
| 360 | FROM Issue |
| 361 | GROUP BY project_id; |
| 362 | |
| 363 | ================================================================ |
| 364 | 2015-06-12: add issue_id to Invalidate's enum for kind. |
| 365 | |
| 366 | ALTER TABLE Invalidate CHANGE kind kind ENUM('user', 'project', 'issue', 'issue_id'); |
| 367 | |
| 368 | ================================================================ |
| 369 | 2015-07-24: Rename blobkey to gcs_object_id because we are using |
| 370 | Google Cloud storage now. |
| 371 | |
| 372 | ALTER TABLE Attachment CHANGE blobkey gcs_object_id VARCHAR(1024) NOT NULL; |
| 373 | |
| 374 | =============================================================== |
| 375 | 2015-08-14: Use MurmurHash3 to deterministically generate user ids. |
| 376 | |
| 377 | -- First, drop foreign key constraints, then alter the keys, then |
| 378 | -- add back the foreign key constraints. |
| 379 | |
| 380 | ALTER TABLE User2Project DROP FOREIGN KEY user2project_ibfk_2; |
| 381 | ALTER TABLE ExtraPerm DROP FOREIGN KEY extraperm_ibfk_2; |
| 382 | ALTER TABLE MemberNotes DROP FOREIGN KEY membernotes_ibfk_2; |
| 383 | ALTER TABLE UserStar DROP FOREIGN KEY userstar_ibfk_1; |
| 384 | ALTER TABLE UserStar DROP FOREIGN KEY userstar_ibfk_2; |
| 385 | ALTER TABLE ProjectStar DROP FOREIGN KEY projectstar_ibfk_1; |
| 386 | ALTER TABLE UserGroup DROP FOREIGN KEY usergroup_ibfk_1; |
| 387 | ALTER TABLE UserGroup DROP FOREIGN KEY usergroup_ibfk_2; |
| 388 | ALTER TABLE UserGroupSettings DROP FOREIGN KEY usergroupsettings_ibfk_1; |
| 389 | ALTER TABLE QuickEditHistory DROP FOREIGN KEY quickedithistory_ibfk_2; |
| 390 | ALTER TABLE QuickEditMostRecent DROP FOREIGN KEY quickeditmostrecent_ibfk_2; |
| 391 | ALTER TABLE Issue DROP FOREIGN KEY issue_ibfk_2; |
| 392 | ALTER TABLE Issue DROP FOREIGN KEY issue_ibfk_3; |
| 393 | ALTER TABLE Issue DROP FOREIGN KEY issue_ibfk_4; |
| 394 | ALTER TABLE Issue2Cc DROP FOREIGN KEY issue2cc_ibfk_2; |
| 395 | ALTER TABLE IssueStar DROP FOREIGN KEY issuestar_ibfk_1; -- ? |
| 396 | ALTER TABLE Issue2FieldValue DROP FOREIGN KEY issue2fieldvalue_ibfk_2; |
| 397 | ALTER TABLE Comment DROP FOREIGN KEY comment_ibfk_3; |
| 398 | ALTER TABLE Comment DROP FOREIGN KEY comment_ibfk_4; |
| 399 | ALTER TABLE FieldDef2Admin DROP FOREIGN KEY fielddef2admin_ibfk_2; |
| 400 | ALTER TABLE Template2Admin DROP FOREIGN KEY template2admin_ibfk_2; |
| 401 | ALTER TABLE Template2FieldValue DROP FOREIGN KEY template2fieldvalue_ibfk_2; |
| 402 | ALTER TABLE Component2Admin DROP FOREIGN KEY component2admin_ibfk_2; |
| 403 | ALTER TABLE Component2Cc DROP FOREIGN KEY component2cc_ibfk_2; |
| 404 | ALTER TABLE User2SavedQuery DROP FOREIGN KEY user2savedquery_ibfk_1; |
| 405 | |
| 406 | |
| 407 | ALTER TABLE User MODIFY user_id INT UNSIGNED NOT NULL; |
| 408 | ALTER TABLE ActionLimit MODIFY user_id INT UNSIGNED NOT NULL; |
| 409 | ALTER TABLE DismissedCues MODIFY user_id INT UNSIGNED NOT NULL; |
| 410 | ALTER TABLE User2Project MODIFY user_id INT UNSIGNED NOT NULL; |
| 411 | ALTER TABLE ExtraPerm MODIFY user_id INT UNSIGNED NOT NULL; |
| 412 | ALTER TABLE MemberNotes MODIFY user_id INT UNSIGNED NOT NULL; |
| 413 | ALTER TABLE UserStar MODIFY starred_user_id INT UNSIGNED NOT NULL, |
| 414 | MODIFY user_id INT UNSIGNED NOT NULL; |
| 415 | ALTER TABLE ProjectStar MODIFY user_id INT UNSIGNED NOT NULL; |
| 416 | ALTER TABLE UserGroup MODIFY user_id INT UNSIGNED NOT NULL; |
| 417 | ALTER TABLE UserGroup MODIFY group_id INT UNSIGNED NOT NULL; |
| 418 | ALTER TABLE UserGroupSettings MODIFY group_id INT UNSIGNED NOT NULL; |
| 419 | ALTER TABLE QuickEditHistory MODIFY user_id INT UNSIGNED NOT NULL; |
| 420 | ALTER TABLE QuickEditMostRecent MODIFY user_id INT UNSIGNED NOT NULL; |
| 421 | ALTER TABLE Issue MODIFY reporter_id INT UNSIGNED NOT NULL, |
| 422 | MODIFY owner_id INT UNSIGNED, |
| 423 | MODIFY derived_owner_id INT UNSIGNED; |
| 424 | ALTER TABLE Issue2Cc MODIFY cc_id INT UNSIGNED NOT NULL; |
| 425 | ALTER TABLE IssueStar MODIFY user_id INT UNSIGNED NOT NULL; |
| 426 | ALTER TABLE Issue2FieldValue MODIFY user_id INT UNSIGNED; |
| 427 | ALTER TABLE Comment MODIFY commenter_id INT UNSIGNED NOT NULL; |
| 428 | ALTER TABLE Comment MODIFY deleted_by INT UNSIGNED; |
| 429 | ALTER TABLE IssueUpdate MODIFY added_user_id INT UNSIGNED, |
| 430 | MODIFY removed_user_id INT UNSIGNED; |
| 431 | ALTER TABLE Template MODIFY owner_id INT UNSIGNED; |
| 432 | ALTER TABLE FieldDef2Admin MODIFY admin_id INT UNSIGNED NOT NULL; |
| 433 | ALTER TABLE Template2Admin MODIFY admin_id INT UNSIGNED NOT NULL; |
| 434 | ALTER TABLE Template2FieldValue MODIFY user_id INT UNSIGNED; |
| 435 | ALTER TABLE Component2Admin MODIFY admin_id INT UNSIGNED NOT NULL; |
| 436 | ALTER TABLE Component2Cc MODIFY cc_id INT UNSIGNED NOT NULL; |
| 437 | ALTER TABLE User2SavedQuery MODIFY user_id INT UNSIGNED NOT NULL; |
| 438 | |
| 439 | ALTER TABLE User2Project ADD CONSTRAINT user2project_ibfk_2 FOREIGN KEY (user_id) REFERENCES User(user_id); |
| 440 | ALTER TABLE ExtraPerm ADD CONSTRAINT extraperm_ibfk_2 FOREIGN KEY (user_id) REFERENCES User(user_id); |
| 441 | ALTER TABLE MemberNotes ADD CONSTRAINT membernotes_ibfk_2 FOREIGN KEY (user_id) REFERENCES User(user_id); |
| 442 | ALTER TABLE UserStar ADD CONSTRAINT userstar_ibfk_1 FOREIGN KEY (user_id) REFERENCES User(user_id); |
| 443 | ALTER TABLE UserStar ADD CONSTRAINT userstar_ibfk_2 FOREIGN KEY (starred_user_id) REFERENCES User(user_id); |
| 444 | ALTER TABLE ProjectStar ADD CONSTRAINT projectstar_ibfk_1 FOREIGN KEY (user_id) REFERENCES User(user_id); |
| 445 | ALTER TABLE UserGroup ADD CONSTRAINT usergroup_ibfk_1 FOREIGN KEY (user_id) REFERENCES User(user_id); |
| 446 | ALTER TABLE UserGroup ADD CONSTRAINT usergroup_ibfk_2 FOREIGN KEY (group_id) REFERENCES User(user_id); |
| 447 | ALTER TABLE UserGroupSettings ADD CONSTRAINT usergroupsettings_ibfk_1 FOREIGN KEY (group_id) REFERENCES User(user_id); |
| 448 | ALTER TABLE QuickEditHistory ADD CONSTRAINT quickedithistory_ibfk_2 FOREIGN KEY (user_id) REFERENCES User(user_id); |
| 449 | ALTER TABLE QuickEditMostRecent ADD CONSTRAINT quickeditmostrecent_ibfk_2 FOREIGN KEY (user_id) REFERENCES User(user_id); |
| 450 | ALTER TABLE Issue ADD CONSTRAINT issue_ibfk_2 FOREIGN KEY (reporter_id) REFERENCES User(user_id); |
| 451 | ALTER TABLE Issue ADD CONSTRAINT issue_ibfk_3 FOREIGN KEY (owner_id) REFERENCES User(user_id); |
| 452 | ALTER TABLE Issue ADD CONSTRAINT issue_ibfk_4 FOREIGN KEY (derived_owner_id) REFERENCES User(user_id); |
| 453 | ALTER TABLE Issue2Cc ADD CONSTRAINT issue2cc_ibfk_2 FOREIGN KEY (cc_id) REFERENCES User(user_id); |
| 454 | ALTER TABLE IssueStar ADD CONSTRAINT issuestar_ibfk_1 FOREIGN KEY (user_id) REFERENCES User(user_id); |
| 455 | ALTER TABLE Issue2FieldValue ADD CONSTRAINT issue2fieldvalue_ibfk_2 FOREIGN KEY (user_id) REFERENCES User(user_id); |
| 456 | ALTER TABLE Comment ADD CONSTRAINT comment_ibfk_3 FOREIGN KEY (commenter_id) REFERENCES User(user_id); |
| 457 | ALTER TABLE Comment ADD CONSTRAINT comment_ibfk_4 FOREIGN KEY (deleted_by) REFERENCES User(user_id); |
| 458 | ALTER TABLE FieldDef2Admin ADD CONSTRAINT fielddef2admin_ibfk_2 FOREIGN KEY (admin_id) REFERENCES User(user_id); |
| 459 | ALTER TABLE Template2Admin ADD CONSTRAINT template2admin_ibfk_2 FOREIGN KEY (admin_id) REFERENCES User(user_id); |
| 460 | ALTER TABLE Template2FieldValue ADD CONSTRAINT template2fieldvalue_ibfk_2 FOREIGN KEY (user_id) REFERENCES User(user_id); |
| 461 | ALTER TABLE Component2Admin ADD CONSTRAINT component2admin_ibfk_2 FOREIGN KEY (admin_id) REFERENCES User(user_id); |
| 462 | ALTER TABLE Component2Cc ADD CONSTRAINT component2cc_ibfk_2 FOREIGN KEY (cc_id) REFERENCES User(user_id); |
| 463 | ALTER TABLE User2SavedQuery ADD CONSTRAINT user2savedquery_ibfk_1 FOREIGN KEY (user_id) REFERENCES User(user_id); |
| 464 | |
| 465 | ================================================================ |
| 466 | 2015-08-20: Add obscure_email column to User. |
| 467 | |
| 468 | ALTER TABLE User ADD obscure_email BOOLEAN DEFAULT TRUE; |
| 469 | |
| 470 | ================================================================ |
| 471 | 2015-09-14: Add role column to UserGroup. |
| 472 | |
| 473 | ALTER TABLE UserGroup ADD COLUMN role ENUM ('owner', 'member') NOT NULL DEFAULT 'member'; |
| 474 | |
| 475 | ================================================================ |
| 476 | 2015-09-14: Remove via_id column from UserGroup. |
| 477 | |
| 478 | ALTER TABLE UserGroup DROP COLUMN via_id; |
| 479 | |
| 480 | ================================================================ |
| 481 | 2015-09-14: Add foreign key constraints to Issue2Foo tables |
| 482 | |
| 483 | ALTER TABLE Issue ADD CONSTRAINT issue_ibfk_5 FOREIGN KEY (status_id) REFERENCES StatusDef(id); |
| 484 | ALTER TABLE Issue2Component ADD CONSTRAINT issue2component_ibfk_2 FOREIGN KEY (component_id) REFERENCES ComponentDef(id); |
| 485 | ALTER TABLE Issue2Label ADD CONSTRAINT issue2label_ibfk_2 FOREIGN KEY (label_id) REFERENCES LabelDef(id); |
| 486 | ALTER TABLE Issue2FieldValue ADD CONSTRAINT issue2fieldvalue_ibfk_3 FOREIGN KEY (field_id) REFERENCES FieldDef(id); |
| 487 | |
| 488 | ================================================================ |
| 489 | 2015-09-16: Use Binary collation on Varchar unique keys |
| 490 | |
| 491 | ALTER TABLE StatusDef MODIFY status VARCHAR(80) BINARY NOT NULL; |
| 492 | ALTER TABLE ComponentDef MODIFY path VARCHAR(255) BINARY NOT NULL; |
| 493 | ALTER TABLE LabelDef MODIFY label VARCHAR(80) BINARY NOT NULL; |
| 494 | ALTER TABLE FieldDef MODIFY field_name VARCHAR(80) BINARY NOT NULL; |
| 495 | ALTER TABLE Template MODIFY name VARCHAR(255) BINARY NOT NULL; |
| 496 | |
| 497 | ================================================================ |
| 498 | 2015-09-16: Have components use the same ID schema as Labels/Statuses |
| 499 | |
| 500 | ALTER TABLE ComponentDef MODIFY id INT NOT NULL AUTO_INCREMENT; |
| 501 | ALTER TABLE Component2Admin MODIFY component_id INT NOT NULL; |
| 502 | ALTER TABLE Component2Cc MODIFY component_id INT NOT NULL; |
| 503 | ALTER TABLE Issue2Component MODIFY component_id INT NOT NULL; |
| 504 | |
| 505 | ================================================================ |
| 506 | 2015-09-17: Introduce DanglingIssueRelation table |
| 507 | |
| 508 | ALTER TABLE IssueRelation ADD CONSTRAINT issuerelation_ibfk_2 FOREIGN KEY (dst_issue_id) REFERENCES Issue(id); |
| 509 | |
| 510 | CREATE TABLE DanglingIssueRelation ( |
| 511 | issue_id INT NOT NULL, |
| 512 | dst_issue_project VARCHAR(80), |
| 513 | dst_issue_local_id INT, |
| 514 | |
| 515 | -- This table uses 'blocking' so that it can guarantee the src issue |
| 516 | -- always exists, while the dst issue is always the dangling one. |
| 517 | kind ENUM ('blockedon', 'blocking', 'mergedinto') NOT NULL, |
| 518 | |
| 519 | PRIMARY KEY (issue_id, dst_issue_project, dst_issue_local_id), |
| 520 | INDEX (issue_id), |
| 521 | FOREIGN KEY (issue_id) REFERENCES Issue(id) |
| 522 | ) ENGINE=INNODB; |
| 523 | |
| 524 | ================================================================ |
| 525 | 2015-09-18: Convert table char encodings to utf8. |
| 526 | |
| 527 | ALTER DATABASE monorail CHARACTER SET = utf8 COLLATE = utf8_unicode_ci; |
| 528 | ALTER TABLE Comment CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci; |
| 529 | ALTER TABLE ComponentDef CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci; |
| 530 | ALTER TABLE FieldDef CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci; |
| 531 | ALTER TABLE IssueSummary CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci; |
| 532 | ALTER TABLE LabelDef CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci; |
| 533 | ALTER TABLE MemberNotes CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci; |
| 534 | ALTER TABLE Project CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci; |
| 535 | ALTER TABLE StatusDef CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci; |
| 536 | |
| 537 | ================================================================ |
| 538 | 2015-09-22: Make IssueRelation primary key more specific |
| 539 | |
| 540 | ALTER TABLE IssueRelation DROP PRIMARY KEY, ADD PRIMARY KEY (issue_id, dst_issue_id, kind); |
| 541 | ALTER TABLE DanglingIssueRelation DROP PRIMARY KEY, ADD PRIMARY KEY (issue_id, dst_issue_project, dst_issue_local_id, kind); |
| 542 | |
| 543 | ================================================================ |
| 544 | 2015-09-29: Make cache_key unsigned so unsigned user ids can be invalidated. |
| 545 | |
| 546 | ALTER TABLE Invalidate MODIFY cache_key INT UNSIGNED NOT NULL; |
| 547 | |
| 548 | ================================================================ |
| 549 | 2015-09-29: Add external_group_type and external_group_name to UserGroupSettings |
| 550 | |
| 551 | ALTER TABLE UserGroupSettings ADD COLUMN external_group_type ENUM ('chrome_infra_auth', 'mdb'); |
| 552 | ALTER TABLE UserGroupSettings ADD COLUMN last_sync_time INT; |
| 553 | |
| 554 | ================================================================ |
| 555 | 2015-10-27: Eliminate Project.deliver_outbound_email because we have separate staging and prod instances. |
| 556 | |
| 557 | ALTER TABLE Project DROP COLUMN deliver_outbound_email; |
| 558 | |
| 559 | ================================================================ |
| 560 | 2015-10-27: Add SpamReport and is_spam fields to Issue and Comment |
| 561 | |
| 562 | ALTER TABLE Issue ADD COLUMN is_spam BOOL DEFAULT FALSE; |
| 563 | ALTER TABLE Issue ADD INDEX (is_spam, project_id); |
| 564 | |
| 565 | ALTER TABLE Comment ADD COLUMN is_spam BOOL DEFAULT FALSE; |
| 566 | ALTER TABLE Comment ADD INDEX (is_spam, project_id, created); |
| 567 | |
| 568 | -- Created whenever a user reports an issue or comment as spam. |
| 569 | -- Note this is distinct from a SpamVerdict, which is issued by |
| 570 | -- the system rather than a human user. |
| 571 | CREATE TABLE SpamReport ( |
| 572 | -- when this report was generated |
| 573 | created TIMESTAMP NOT NULL, |
| 574 | -- when the reported content was generated |
| 575 | content_created TIMESTAMP NOT NULL, |
| 576 | -- id of the reporting user |
| 577 | user_id INT UNSIGNED NOT NULL, |
| 578 | -- id of the reported user |
| 579 | reported_user_id INT UNSIGNED NOT NULL, |
| 580 | -- either this or issue_id must be set |
| 581 | comment_id INT, |
| 582 | -- either this or comment_id must be set |
| 583 | issue_id INT, |
| 584 | |
| 585 | INDEX (issue_id), |
| 586 | INDEX (comment_id), |
| 587 | FOREIGN KEY (issue_id) REFERENCES Issue(id), |
| 588 | FOREIGN KEY (comment_id) REFERENCES Comment(id) |
| 589 | ); |
| 590 | |
| 591 | ================================================================ |
| 592 | 2015-11-03: Add new external group type chromium_committers |
| 593 | |
| 594 | ALTER TABLE UserGroupSettings MODIFY COLUMN external_group_type ENUM ('chrome_infra_auth', 'mdb', 'chromium_committers'); |
| 595 | |
| 596 | ================================================================ |
| 597 | 2015-11-4: Add SpamVerdict table. |
| 598 | |
| 599 | -- Any time a human or the system sets is_spam to true, |
| 600 | -- or changes it from true to false, we want to have a |
| 601 | -- record of who did it and why. |
| 602 | CREATE TABLE SpamVerdict ( |
| 603 | -- when this verdict was generated |
| 604 | created TIMESTAMP NOT NULL, |
| 605 | |
| 606 | -- id of the reporting user, may be null if it was |
| 607 | -- an automatic classification. |
| 608 | user_id INT UNSIGNED, |
| 609 | |
| 610 | -- either this or issue_id must be set |
| 611 | comment_id INT, |
| 612 | |
| 613 | -- either this or comment_id must be set |
| 614 | issue_id INT, |
| 615 | |
| 616 | INDEX (issue_id), |
| 617 | INDEX (comment_id), |
| 618 | FOREIGN KEY (issue_id) REFERENCES Issue(id), |
| 619 | FOREIGN KEY (comment_id) REFERENCES Comment(id), |
| 620 | |
| 621 | -- If the classifier issued the verdict, this should |
| 622 | -- be set. |
| 623 | classifier_confidence FLOAT, |
| 624 | |
| 625 | -- This should reflect the new is_spam value that was applied |
| 626 | -- by this verdict, not the value it had prior. |
| 627 | is_spam BOOLEAN NOT NULL, |
| 628 | |
| 629 | -- owner: a project owner marked it as spam |
| 630 | -- threshhold: number of SpamReports from non-members was exceeded. |
| 631 | -- classifier: the automatic classifier reports it as spam. |
| 632 | reason ENUM ("manual", "threshold", "classifier") NOT NULL |
| 633 | ); |
| 634 | |
| 635 | ALTER TABLE LocalIDCounter ADD used_spam_id int(11) NOT NULL; |
| 636 | |
| 637 | ================================================================ |
| 638 | 2015-11-13: Add Template2Component table. |
| 639 | |
| 640 | CREATE TABLE Template2Component ( |
| 641 | template_id INT NOT NULL, |
| 642 | component_id INT NOT NULL, |
| 643 | |
| 644 | PRIMARY KEY (template_id, component_id), |
| 645 | |
| 646 | FOREIGN KEY (template_id) REFERENCES Template(id), |
| 647 | FOREIGN KEY (component_id) REFERENCES ComponentDef(id) |
| 648 | ) ENGINE=INNODB; |
| 649 | |
| 650 | ================================================================ |
| 651 | 2015-11-13: Add new external group type baggins |
| 652 | |
| 653 | ALTER TABLE UserGroupSettings MODIFY COLUMN external_group_type ENUM ('chrome_infra_auth', 'mdb', 'chromium_committers', 'baggins'); |
| 654 | |
| 655 | ================================================================ |
| 656 | 2015-11-18: Add new action kind api_request in ActionLimit |
| 657 | |
| 658 | ALTER TABLE ActionLimit MODIFY COLUMN action_kind ENUM ('project_creation', 'issue_comment', 'issue_attachment', 'issue_bulk_edit', 'api_request'); |
| 659 | |
| 660 | ================================================================ |
| 661 | 2015-11-24: Add shard column to Issue, add indexes, and UPDATE existing rows. |
| 662 | |
| 663 | ALTER TABLE Issue ADD COLUMN shard SMALLINT UNSIGNED DEFAULT 0 NOT NULL; |
| 664 | |
| 665 | UPDATE Issue set shard = id % 10; |
| 666 | |
| 667 | ALTER TABLE Issue ADD INDEX (shard, status_id); |
| 668 | ALTER TABLE Issue ADD INDEX (shard, project_id); |
| 669 | |
| 670 | ================================================================ |
| 671 | 2015-11-25: Remove external group type chromium_committers |
| 672 | |
| 673 | ALTER TABLE UserGroupSettings MODIFY COLUMN external_group_type ENUM ('chrome_infra_auth', 'mdb', 'baggins'); |
| 674 | |
| 675 | ================================================================ |
| 676 | 2015-12-08: Modify handling of hidden well-known labels/statuses |
| 677 | |
| 678 | ALTER TABLE StatusDef ADD COLUMN hidden BOOLEAN DEFAULT FALSE; |
| 679 | ALTER TABLE LabelDef ADD COLUMN hidden BOOLEAN DEFAULT FALSE; |
| 680 | |
| 681 | UPDATE StatusDef SET status=TRIM(LEADING '#' FROM status), hidden=TRUE WHERE status COLLATE UTF8_GENERAL_CI LIKE '#%'; |
| 682 | UPDATE LabelDef SET label=TRIM(LEADING '#' FROM label), hidden=TRUE WHERE label COLLATE UTF8_GENERAL_CI LIKE '#%'; |
| 683 | |
| 684 | ================================================================ |
| 685 | 2015-12-11: Speed up moderation queue queries. |
| 686 | |
| 687 | ALTER TABLE SpamVerdict ADD INDEX(classifier_confidence); |
| 688 | |
| 689 | ================================================================ |
| 690 | 2015-12-14: Give components 'deprecated' col to match labels/statuses |
| 691 | |
| 692 | ALTER TABLE StatusDef CHANGE hidden deprecated BOOLEAN DEFAULT FALSE; |
| 693 | ALTER TABLE LabelDef CHANGE hidden deprecated BOOLEAN DEFAULT FALSE; |
| 694 | ALTER TABLE ComponentDef ADD COLUMN deprecated BOOLEAN DEFAULT FALSE; |
| 695 | |
| 696 | ================================================================ |
| 697 | 2015-12-14: Add table Group2Project |
| 698 | |
| 699 | CREATE TABLE Group2Project ( |
| 700 | group_id INT UNSIGNED NOT NULL, |
| 701 | project_id SMALLINT UNSIGNED NOT NULL, |
| 702 | |
| 703 | PRIMARY KEY (group_id, project_id), |
| 704 | |
| 705 | FOREIGN KEY (group_id) REFERENCES UserGroupSettings(group_id), |
| 706 | FOREIGN KEY (project_id) REFERENCES Project(project_id) |
| 707 | ) ENGINE=INNODB; |
| 708 | |
| 709 | ================================================================ |
| 710 | 2015-12-15: Increase maximum attachment quota bytes |
| 711 | |
| 712 | ALTER TABLE Project MODIFY attachment_bytes_used BIGINT DEFAULT 0; |
| 713 | ALTER TABLE Project MODIFY attachment_quota BIGINT DEFAULT 0; |
| 714 | |
| 715 | ================================================================ |
| 716 | 2015-12-15: Simplify moderation queue queries. |
| 717 | |
| 718 | ALTER TABLE SpamVerdict ADD COLUMN overruled BOOL NOT NULL; |
| 719 | ALTER TABLE SpamVerdict ADD COLUMN project_id INT NOT NULL; |
| 720 | UPDATE SpamVerdict s JOIN Issue i ON i.id=s.issue_id SET s.project_id=i.project_id; |
| 721 | |
| 722 | ================================================================ |
| 723 | 2015-12-17: Add cols home_page and logo to table Project |
| 724 | |
| 725 | ALTER TABLE Project ADD COLUMN home_page VARCHAR(250); |
| 726 | ALTER TABLE Project ADD COLUMN logo_gcs_id VARCHAR(250); |
| 727 | ALTER TABLE Project ADD COLUMN logo_file_name VARCHAR(250); |
| 728 | |
| 729 | ================================================================ |
| 730 | 2015-12-28: Add component_required col to table Template; |
| 731 | |
| 732 | ALTER TABLE Template ADD component_required BOOLEAN DEFAULT FALSE; |
| 733 | |
| 734 | ================================================================ |
| 735 | 2016-01-05: Add issue_shard column to Issue2Label, Issue2Component, |
| 736 | add indexes, and UPDATE existing rows. |
| 737 | |
| 738 | ALTER TABLE Issue2Component ADD COLUMN issue_shard SMALLINT UNSIGNED DEFAULT 0 NOT NULL; |
| 739 | UPDATE Issue2Component set issue_shard = issue_id % 10; |
| 740 | ALTER TABLE Issue2Component ADD INDEX (component_id, issue_shard); |
| 741 | |
| 742 | ALTER TABLE Issue2Label ADD COLUMN issue_shard SMALLINT UNSIGNED DEFAULT 0 NOT NULL; |
| 743 | UPDATE Issue2Label set issue_shard = issue_id % 10; |
| 744 | ALTER TABLE Issue2Label ADD INDEX (label_id, issue_shard); |
| 745 | |
| 746 | ================================================================ |
| 747 | 2016-01-06: Add period_soft_limit and period_hard_limit columns to ActionLimit |
| 748 | |
| 749 | ALTER TABLE ActionLimit ADD COLUMN period_soft_limit INT; |
| 750 | ALTER TABLE ActionLimit ADD COLUMN period_hard_limit INT; |
| 751 | |
| 752 | ================================================================ |
| 753 | 2016-01-08: Add issue_shard column to Issue2FieldValue, Issue2Cc, |
| 754 | add indexes, and UPDATE existing rows. |
| 755 | |
| 756 | ALTER TABLE Issue2FieldValue ADD COLUMN issue_shard SMALLINT UNSIGNED DEFAULT 0 NOT NULL; |
| 757 | UPDATE Issue2FieldValue SET issue_shard = issue_id % 10; |
| 758 | ALTER TABLE Issue2FieldValue ADD INDEX (field_id, issue_shard, int_value); |
| 759 | ALTER TABLE Issue2FieldValue ADD INDEX (field_id, issue_shard, str_value(255)); |
| 760 | ALTER TABLE Issue2FieldValue ADD INDEX (field_id, issue_shard, user_id); |
| 761 | |
| 762 | ALTER TABLE Issue2Cc ADD COLUMN issue_shard SMALLINT UNSIGNED DEFAULT 0 NOT NULL; |
| 763 | UPDATE Issue2Cc SET issue_shard = issue_id % 10; |
| 764 | ALTER TABLE Issue2Cc ADD INDEX (cc_id, issue_shard); |
| 765 | |
| 766 | ================================================================ |
| 767 | 2015-12-17: Add documentation forwarding for /wiki urls |
| 768 | |
| 769 | ALTER TABLE Project ADD COLUMN docs_url VARCHAR(250); |
| 770 | |
| 771 | ================================================================ |
| 772 | 2015-12-17: Ensure SavedQueries never have null ids |
| 773 | |
| 774 | ALTER TABLE SavedQuery MODIFY id INT NOT NULL AUTO INCREMENT; |
| 775 | |
| 776 | ================================================================ |
| 777 | 2016-02-04: Add created, creator_id, modified, modifier_id for components |
| 778 | |
| 779 | ALTER TABLE ComponentDef ADD COLUMN created INT; |
| 780 | ALTER TABLE ComponentDef ADD COLUMN creator_id INT UNSIGNED; |
| 781 | ALTER TABLE ComponentDef ADD FOREIGN KEY (creator_id) REFERENCES User(user_id); |
| 782 | ALTER TABLE ComponentDef ADD COLUMN modified INT; |
| 783 | ALTER TABLE ComponentDef ADD COLUMN modifier_id INT UNSIGNED; |
| 784 | ALTER TABLE ComponentDef ADD FOREIGN KEY (modifier_id) REFERENCES User(user_id); |
| 785 | |
| 786 | ================================================================ |
| 787 | 2016-02-19: Opt all privileged accounts into displaying full email. |
| 788 | |
| 789 | UPDATE User SET obscure_email = FALSE WHERE email LIKE "%@chromium.org"; |
| 790 | UPDATE User SET obscure_email = FALSE WHERE email LIKE "%@webrtc.org"; |
| 791 | UPDATE User SET obscure_email = FALSE WHERE email LIKE "%@google.com"; |
| 792 | |
| 793 | ================================================================ |
| 794 | 2016-04-11: Increase email length limit to 255 |
| 795 | |
| 796 | ALTER TABLE User MODIFY email VARCHAR(255); |
| 797 | |
| 798 | ================================================================ |
| 799 | 2016-04-14: Add forwarding for /source urls |
| 800 | |
| 801 | ALTER TABLE Project ADD COLUMN source_url VARCHAR(250); |
| 802 | |
| 803 | ================================================================ |
| 804 | 2016-04-27: Add prefs for compact email subject lines |
| 805 | |
| 806 | ALTER TABLE User ADD COLUMN email_compact_subject BOOLEAN DEFAULT FALSE; |
| 807 | ALTER TABLE User ADD COLUMN email_view_widget BOOLEAN DEFAULT TRUE; |
| 808 | |
| 809 | ================================================================ |
| 810 | 2016-05-13: Add component labels |
| 811 | |
| 812 | CREATE TABLE Component2Label ( |
| 813 | component_id INT NOT NULL, |
| 814 | label_id INT NOT NULL, |
| 815 | |
| 816 | PRIMARY KEY (component_id, label_id), |
| 817 | |
| 818 | FOREIGN KEY (component_id) REFERENCES ComponentDef(id), |
| 819 | FOREIGN KEY (label_id) REFERENCES LabelDef(id) |
| 820 | ) ENGINE=INNODB; |
| 821 | |
| 822 | ================================================================ |
| 823 | 2016-05-23: Add default search for members |
| 824 | |
| 825 | ALTER TABLE ProjectIssueConfig ADD COLUMN member_default_query TEXT; |
| 826 | |
| 827 | ================================================================ |
| 828 | 2016-06-17: Add is_description column to Comment |
| 829 | |
| 830 | Local: |
| 831 | % pt-online-schema-change --alter "ADD COLUMN is_description BOOLEAN DEFAULT FALSE" D=monorail,t=Comment --host=localhost --user=root --alter-foreign-keys-method=rebuild_constraints --execute |
| 832 | |
| 833 | Staging/Production: |
| 834 | % pt-online-schema-change --alter "ADD COLUMN is_description BOOLEAN DEFAULT FALSE" D=monorail,t=Comment,h=<primary IP address>,u=$USER,p=test --alter-forieign-keys-method=rebuild_constraints --recursion-method=hosts --execute |
| 835 | |
| 836 | ================================================================ |
| 837 | 2016-05-13: Add table AutocompleteExclusion |
| 838 | |
| 839 | CREATE TABLE AutocompleteExclusion ( |
| 840 | project_id SMALLINT UNSIGNED NOT NULL, |
| 841 | user_id INT UNSIGNED NOT NULL, |
| 842 | |
| 843 | PRIMARY KEY (project_id, user_id), |
| 844 | FOREIGN KEY (project_id) REFERENCES Project(project_id), |
| 845 | FOREIGN KEY (user_id) REFERENCES User(user_id) |
| 846 | ) ENGINE=INNODB; |
| 847 | |
| 848 | =============================================================== |
| 849 | 2016-06-30: Update table character encodings to allow Emoji support. |
| 850 | |
| 851 | /* DO NOT RUN THESE STATEMENTS ON PROD OR STAGING. They are fine for localhost |
| 852 | but be warned they will lock the db for some time if you have gigs of data in |
| 853 | these tables */ |
| 854 | |
| 855 | ALTER TABLE `monorail`.`Comment` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; |
| 856 | ALTER TABLE `monorail`.`IssueUpdate` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; |
| 857 | ALTER TABLE `monorail`.`IssueSummary` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; |
| 858 | |
| 859 | /* This is what I ran on production: */ |
| 860 | % pt-online-schema-change --alter "CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" D=monorail,t=Comment,h=<primary IP> --alter-foreign-keys-method=rebuild_constraints --no-drop-old-table --recursion-method=hosts --check-slave-lag=h=<one of the replicas' IP> --print --execute |
| 861 | |
| 862 | % pt-online-schema-change --alter "CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" D=monorail,t=IssueUpdate,h=<primary IP> --alter-foreign-keys-method=rebuild_constraints --no-drop-old-table --recursion-method=hosts --check-slave-lag=h=<one of the replicas' IP> --print --execute |
| 863 | |
| 864 | % pt-online-schema-change --alter "CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" D=monorail,t=IssueSummary,h=<primary IP> --alter-foreign-keys-method=rebuild_constraints --no-drop-old-table --recursion-method=hosts --check-slave-lag=h=<one of the replicas' IP> --print --execute |
| 865 | |
| 866 | /* And then these two which ran very quickly: */ |
| 867 | ALTER TABLE `monorail`.`Template` CHANGE `content` `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; |
| 868 | ALTER TABLE `monorail`.`Template` CHANGE `summary` `summary` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; |
| 869 | |
| 870 | =============================================================== |
| 871 | 2016-07-07: Add rank to IssueRelation |
| 872 | |
| 873 | ALTER TABLE IssueRelation ADD COLUMN rank BIGINT; |
| 874 | |
| 875 | ============================================================== |
| 876 | 2016-07-13: Set default rank for blockedon relations |
| 877 | |
| 878 | UPDATE IssueRelation SET rank = 0 WHERE kind = 'blockedon'; |
| 879 | |
| 880 | ================================================================ |
| 881 | 2016-08-01: Add timestamps for issue field changes |
| 882 | |
| 883 | DO NOT RUN THIS STATEMENT ON PROD OR STAGING. It is fine for localhost |
| 884 | but be warned that it will lock the db for some time if you have gigs of data in |
| 885 | these tables. |
| 886 | ALTER TABLE Issue |
| 887 | ADD COLUMN owner_modified INT, |
| 888 | ADD COLUMN status_modified INT, |
| 889 | ADD COLUMN component_modified INT; |
| 890 | |
| 891 | Staging/Production: |
| 892 | % pt-online-schema-change \ |
| 893 | --alter "ADD COLUMN owner_modified INT, ADD COLUMN status_modified INT, ADD COLUMN component_modified INT" \ |
| 894 | D=monorail,t=Issue,h=<primary IP address>,u=$USER,p=<your mysql password> \ |
| 895 | --alter-foreign-keys-method=rebuild_constraints --recursion-method=hosts --execute |
| 896 | |
| 897 | ============================================================== |
| 898 | 2016-08-05: Add tables Hotlist, Hotlist2Issue, Hotlist2User |
| 899 | |
| 900 | CREATE TABLE Hotlist ( |
| 901 | id INT UNSIGNED NOT NULL AUTO_INCREMENT, |
| 902 | name VARCHAR(80) NOT NULL, |
| 903 | |
| 904 | summary TEXT, |
| 905 | description TEXT, |
| 906 | |
| 907 | is_private BOOLEAN DEFAULT FALSE, |
| 908 | |
| 909 | PRIMARY KEY (id) |
| 910 | ) ENGINE=INNODB; |
| 911 | |
| 912 | |
| 913 | CREATE TABLE Hotlist2Issue ( |
| 914 | hotlist_id INT UNSIGNED NOT NULL, |
| 915 | issue_id INT NOT NULL, |
| 916 | |
| 917 | rank BIGINT NOT NULL, |
| 918 | |
| 919 | PRIMARY KEY (hotlist_id, issue_id), |
| 920 | INDEX (hotlist_id), |
| 921 | INDEX (issue_id), |
| 922 | FOREIGN KEY (hotlist_id) REFERENCES Hotlist(id), |
| 923 | FOREIGN KEY (issue_id) REFERENCES Issue(id) |
| 924 | ) ENGINE=INNODB; |
| 925 | |
| 926 | |
| 927 | CREATE TABLE Hotlist2User ( |
| 928 | hotlist_id INT UNSIGNED NOT NULL, |
| 929 | user_id INT UNSIGNED NOT NULL, |
| 930 | |
| 931 | role_name ENUM ('owner', 'member', 'follower') NOT NULL, |
| 932 | |
| 933 | PRIMARY KEY (hotlist_id, user_id), |
| 934 | INDEX (hotlist_id), |
| 935 | INDEX (user_id), |
| 936 | FOREIGN KEY (hotlist_id) REFERENCES Hotlist(id), |
| 937 | FOREIGN KEY (user_id) REFERENCES User(user_id) |
| 938 | ) ENGINE=INNODB; |
| 939 | |
| 940 | ============================================================== |
| 941 | 2016-08-10: Improve Hotlist schema |
| 942 | |
| 943 | ALTER TABLE Hotlist ADD COLUMN default_col_spec TEXT; |
| 944 | |
| 945 | ALTER TABLE Hotlist2User CHANGE role_name |
| 946 | role_name ENUM('owner', 'editor', 'follower'); |
| 947 | |
| 948 | ============================================================== |
| 949 | 2016-08-15: Add hotlist to Invalidate table |
| 950 | |
| 951 | ALTER TABLE Invalidate CHANGE kind |
| 952 | kind ENUM('user', 'project', 'issue', 'issue_id', 'hotlist'); |
| 953 | |
| 954 | ================================================================ |
| 955 | 2016-09-21: Create the CommentContent table with emoji support. |
| 956 | |
| 957 | CREATE TABLE CommentContent ( |
| 958 | id INT NOT NULL AUTO_INCREMENT, |
| 959 | -- TODO(jrobbins): drop comment_id after Comment.commentcontent_id is added. |
| 960 | comment_id INT NOT NULL, -- Note: no forign key reference. |
| 961 | content MEDIUMTEXT COLLATE utf8mb4_unicode_ci, |
| 962 | inbound_message MEDIUMTEXT COLLATE utf8mb4_unicode_ci, |
| 963 | |
| 964 | PRIMARY KEY (id), |
| 965 | UNIQUE KEY (comment_id) -- TODO: drop this too. |
| 966 | ) ENGINE=INNODB CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; |
| 967 | |
| 968 | To copy comment strings from Comment to CommentContent, use |
| 969 | the SQL procedure in monorail/tools/copy-comment-to-commentcontent.sql. |
| 970 | |
| 971 | If you need to roll back, you can reverse the process by reading |
| 972 | and carefully using the SQL procedure in |
| 973 | monorail/tools/copy-new-commentcontent-back-to-comment.sql. |
| 974 | |
| 975 | Optionally, after you have all comment content strings in |
| 976 | CommentContent, you can reduce the size of the Comment table by using |
| 977 | the procedure in monorail/tools/null-comment-table-strings.sql. |
| 978 | This can make it faster to make more changes to the Comment table. |
| 979 | |
| 980 | ================================================================ |
| 981 | 2016-09-29: Drop was_escaped after Comment table is made smaller |
| 982 | |
| 983 | ALTER TABLE Comment DROP COLUMN was_escaped; |
| 984 | |
| 985 | ================================================================ |
| 986 | 2016-10-03: Add date-type custom fields |
| 987 | |
| 988 | ALTER TABLE Issue2FieldValue ADD date_value INT; |
| 989 | ALTER TABLE Issue2FieldValue ADD INDEX (field_id, issue_shard, date_value); |
| 990 | ALTER TABLE Template2FieldValue ADD date_value INT; |
| 991 | ALTER TABLE FieldDef CHANGE field_type field_type ENUM ( |
| 992 | 'enum_type', 'int_type', 'str_type', 'user_type', 'date_type') NOT NULL; |
| 993 | |
| 994 | ================================================================ |
| 995 | 2016-10-13: Follow-up on splitting the Comment table |
| 996 | |
| 997 | ALTER TABLE Comment |
| 998 | DROP COLUMN content, |
| 999 | DROP COLUMN inbound_message, |
| 1000 | ADD COLUMN commentcontent_id INT; |
| 1001 | |
| 1002 | ALTER TABLE Comment |
| 1003 | ADD FOREIGN KEY (commentcontent_id) REFERENCES CommentContent(id); |
| 1004 | |
| 1005 | After making those schema changes, run the commands in |
| 1006 | tools/backfill-commentcontent-id.sql to fill in commentcontent_id |
| 1007 | for existing comments. |
| 1008 | |
| 1009 | ================================================================ |
| 1010 | 2016-10-13: Add new User fields |
| 1011 | |
| 1012 | ALTER TABLE User |
| 1013 | ADD COLUMN last_visit_timestamp INT, |
| 1014 | ADD COLUMN email_bounce_timestamp INT, |
| 1015 | ADD COLUMN vacation_message VARCHAR(80); |
| 1016 | |
| 1017 | ================================================================ |
| 1018 | 2016-11-30: Drop unique key constraint on CommentContent.comment_id. |
| 1019 | This is a prerequiste for deleting the code that sets a value for |
| 1020 | that column. This resolves one TODO from 2016-09-21. Later the |
| 1021 | column itself can be dropped, which is the other TODO from 2016-09-21. |
| 1022 | |
| 1023 | ALTER TABLE CommentContent DROP INDEX comment_id; |
| 1024 | |
| 1025 | ================================================================ |
| 1026 | 2016-12-20: Add a table to keep track of hotlists that users have |
| 1027 | starred. |
| 1028 | |
| 1029 | CREATE TABLE HotlistStar ( |
| 1030 | hotlist_id INT UNSIGNED NOT NULL, |
| 1031 | user_id INT UNSIGNED NOT NULL, |
| 1032 | |
| 1033 | PRIMARY KEY (hotlist_id, user_id), |
| 1034 | INDEX (user_id), |
| 1035 | FOREIGN KEY (hotlist_id) REFERENCES Hotlist(id), |
| 1036 | FOREIGN KEY (user_id) REFERENCES User(user_id) |
| 1037 | ) ENGINE=INNODB; |
| 1038 | |
| 1039 | ================================================================ |
| 1040 | 2017-12-04: Add two new columns to Hotlist2Issue. |
| 1041 | |
| 1042 | ALTER TABLE Hotlist2Issue |
| 1043 | ADD COLUMN adder_id INT UNSIGNED, |
| 1044 | ADD COLUMN added INT, |
| 1045 | ADD FOREIGN KEY (adder_id) REFERENCES User(user_id); |
| 1046 | |
| 1047 | ================================================================ |
| 1048 | 2017-01-30: Add one new column to SpamVerdict. |
| 1049 | |
| 1050 | ALTER TABLE SpamVerdict CHANGE reason |
| 1051 | reason ENUM ("manual", "threshold", "classifier", "fail_open") NOT NULL; |
| 1052 | |
| 1053 | ================================================================ |
| 1054 | 2017-02-1: Add two tables to keep track of hotlists and bugs |
| 1055 | that users have visited |
| 1056 | |
| 1057 | CREATE TABLE HotlistVisitHistory ( |
| 1058 | hotlist_id INT UNSIGNED NOT NULL, |
| 1059 | user_id INT UNSIGNED NOT NULL, |
| 1060 | viewed INT NOT NULL, |
| 1061 | |
| 1062 | PRIMARY KEY (user_id, hotlist_id), |
| 1063 | FOREIGN KEY (hotlist_id) REFERENCES Hotlist(id), |
| 1064 | FOREIGN KEY (user_id) REFERENCES User(user_id) |
| 1065 | ) ENGINE=INNODB; |
| 1066 | |
| 1067 | CREATE TABLE IssueVisitHistory ( |
| 1068 | issue_id INT NOT NULL, |
| 1069 | user_id INT UNSIGNED NOT NULL, |
| 1070 | viewed INT NOT NULL, |
| 1071 | |
| 1072 | PRIMARY KEY (user_id, issue_id), |
| 1073 | FOREIGN KEY (issue_id) REFERENCES Issue(id), |
| 1074 | FOREIGN KEY (user_id) REFERENCES User(user_id) |
| 1075 | ) ENGINE=INNODB; |
| 1076 | |
| 1077 | |
| 1078 | ================================================================ |
| 1079 | 2017-02-16: Add 'note' column to Hotlist2Issue table. |
| 1080 | |
| 1081 | ALTER TABLE Hotlist2Issue ADD COLUMN note TEXT; |
| 1082 | |
| 1083 | |
| 1084 | ================================================================ |
| 1085 | 2017-02-23: Add 'is_niche' column to FieldDef table. |
| 1086 | |
| 1087 | ALTER TABLE FieldDef ADD COLUMN is_niche BOOLEAN; |
| 1088 | |
| 1089 | |
| 1090 | ================================================================ |
| 1091 | 2017-03-05: Add 'ping_who' column to FieldDef table. |
| 1092 | |
| 1093 | ALTER TABLE FieldDef |
| 1094 | ADD COLUMN date_action ENUM ('no_action', 'ping_owner_only', 'ping_participants'); |
| 1095 | |
| 1096 | |
| 1097 | ================================================================ |
| 1098 | 2017-05-02: Add index to make commentby: query term faster. |
| 1099 | |
| 1100 | ALTER TABLE Comment ADD INDEX (commenter_id, deleted_by, issue_id); |
| 1101 | |
| 1102 | |
| 1103 | ================================================================ |
| 1104 | 2017-05-12: Add user preference to ping issue starrers. |
| 1105 | |
| 1106 | ALTER TABLE User ADD COLUMN notify_starred_ping BOOLEAN DEFAULT FALSE; |
| 1107 | |
| 1108 | ================================================================ |
| 1109 | 2017-06-15: Add table to map @google.com to @chromium.org accounts. |
| 1110 | |
| 1111 | CREATE TABLE LinkedAccount ( |
| 1112 | parent_email VARCHAR(255) NOT NULL, -- lowercase |
| 1113 | child_email VARCHAR(255) NOT NULL, -- lowercase |
| 1114 | |
| 1115 | KEY (parent_email), |
| 1116 | UNIQUE KEY (child_email) |
| 1117 | ) ENGINE=INNODB; |
| 1118 | |
| 1119 | ================================================================ |
| 1120 | 2017-11-14: Add field_type ENUM url_type to FieldDef. |
| 1121 | |
| 1122 | ALTER TABLE FieldDef MODIFY field_type ENUM ( |
| 1123 | 'enum_type', 'int_type', 'str_type', 'user_type', 'date_type', 'url_type') NOT NULL; |
| 1124 | |
| 1125 | ALTER TABLE Issue2FieldValue ADD COLUMN url_value VARCHAR(1024); |
| 1126 | ALTER TABLE Issue2FieldValue ADD INDEX (field_id, url_value); |
| 1127 | |
| 1128 | ================================================================ |
| 1129 | 2017-11-22: Add url_value column to Template2FieldValue table. |
| 1130 | |
| 1131 | ALTER TABLE Template2FieldValue ADD COLUMN url_value VARCHAR(1024); |
| 1132 | |
| 1133 | ================================================================ |
| 1134 | 2018-01-22: Add table to keep track of the latest timestamp that issues with |
| 1135 | their component data were collected and uploaded to GCS. |
| 1136 | |
| 1137 | CREATE TABLE ComponentIssueClosedIndex ( |
| 1138 | closed_index INT NOT NULL, |
| 1139 | PRIMARY KEY (closed_index) |
| 1140 | ) ENGINE=INNODB; |
| 1141 | |
| 1142 | ================================================================ |
| 1143 | 2018-01-22: Add approval tables and approval_type to FieldDef. |
| 1144 | |
| 1145 | ALTER TABLE FieldDef MODIFY field_type ENUM ( |
| 1146 | 'enum_type', 'int_type', 'str_type', 'user_type', 'date_type', 'url_type', 'approval_type') NOT NULL; |
| 1147 | |
| 1148 | CREATE TABLE ApprovalStatusDef ( |
| 1149 | id INT NOT NULL AUTO_INCREMENT, |
| 1150 | field_id INT NOT NULL, |
| 1151 | status VARCHAR(80) BINARY NOT NULL, |
| 1152 | docstring TEXT, |
| 1153 | |
| 1154 | PRIMARY KEY (id), |
| 1155 | UNIQUE KEY (field_id, status), |
| 1156 | FOREIGN KEY (field_id) REFERENCES FieldDef(id) |
| 1157 | ) ENGINE=INNODB; |
| 1158 | |
| 1159 | CREATE TABLE Issue2ApprovalValue ( |
| 1160 | issue_id INT NOT NULL, |
| 1161 | issue_shard SMALLINT UNSIGNED DEFAULT 0 NOT NULL, |
| 1162 | field_id INT NOT NULL, |
| 1163 | status_id INT NOT NULL, |
| 1164 | setter_id INT UNSIGNED, |
| 1165 | set_on INT, |
| 1166 | |
| 1167 | PRIMARY KEY (issue_id, field_id), |
| 1168 | INDEX (field_id, issue_shard, status_id), |
| 1169 | INDEX (field_id, issue_shard, setter_id), |
| 1170 | INDEX (field_id, issue_shard, set_on), |
| 1171 | |
| 1172 | FOREIGN KEY (issue_id) REFERENCES Issue(id), |
| 1173 | FOREIGN KEY (field_id) REFERENCES FieldDef(id), |
| 1174 | FOREIGN KEY (status_id) REFERENCES ApprovalStatusDef(id), |
| 1175 | FOREIGN KEY (setter_id) REFERENCES User(user_id) |
| 1176 | ) ENGINE=INNODB; |
| 1177 | |
| 1178 | CREATE TABLE Approval2Approvers ( |
| 1179 | field_id INT NOT NULL, |
| 1180 | approver_id INT UNSIGNED NOT NULL, |
| 1181 | issue_id INT, |
| 1182 | issue_shard SMALLINT UNSIGNED DEFAULT 0 NOT NULL, |
| 1183 | |
| 1184 | PRIMARY KEY (issue_id, field_id, approver_id), |
| 1185 | INDEX (approver_id, field_id, issue_shard), |
| 1186 | |
| 1187 | FOREIGN KEY (field_id) REFERENCES FieldDef(id), |
| 1188 | FOREIGN KEY (approver_id) REFERENCES User(user_id), |
| 1189 | FOREIGN KEY (issue_id) REFERENCES Issue(id) |
| 1190 | ) ENGINE=INNODB; |
| 1191 | |
| 1192 | ================================================================ |
| 1193 | 2018-01-29: Add is_deleted column to ComponentDef table and remove |
| 1194 | uniqueness constraint for component names in a project. |
| 1195 | |
| 1196 | ALTER TABLE ComponentDef ADD COLUMN is_deleted BOOLEAN DEFAULT FALSE; |
| 1197 | ALTER TABLE ComponentDef ADD INDEX project_id2 (project_id, path); |
| 1198 | ALTER TABLE ComponentDef DROP INDEX project_id; |
| 1199 | |
| 1200 | ================================================================ |
| 1201 | 2018-01-30: Add IssueSnapshot table and join tables |
| 1202 | |
| 1203 | CREATE TABLE IssueSnapshot ( |
| 1204 | id INT NOT NULL AUTO_INCREMENT, |
| 1205 | issue_id INT NOT NULL, |
| 1206 | shard SMALLINT UNSIGNED DEFAULT 0 NOT NULL, |
| 1207 | project_id SMALLINT UNSIGNED NOT NULL, |
| 1208 | local_id INT NOT NULL, |
| 1209 | reporter_id INT UNSIGNED NOT NULL, |
| 1210 | owner_id INT UNSIGNED, |
| 1211 | status_id INT NOT NULL, |
| 1212 | period_start INT NOT NULL, |
| 1213 | period_end INT NOT NULL, |
| 1214 | is_open BOOLEAN DEFAULT TRUE, |
| 1215 | |
| 1216 | PRIMARY KEY (id), |
| 1217 | FOREIGN KEY (project_id) REFERENCES Project(project_id), |
| 1218 | FOREIGN KEY (reporter_id) REFERENCES User(user_id), |
| 1219 | FOREIGN KEY (owner_id) REFERENCES User(user_id), |
| 1220 | FOREIGN KEY (status_id) REFERENCES StatusDef(id), |
| 1221 | INDEX (shard, project_id, period_start, period_end), |
| 1222 | UNIQUE KEY (issue_id, period_start, period_end) |
| 1223 | ) ENGINE=INNODB; |
| 1224 | |
| 1225 | CREATE TABLE IssueSnapshot2Component ( |
| 1226 | issuesnapshot_id INT NOT NULL, |
| 1227 | component_id INT NOT NULL, |
| 1228 | |
| 1229 | PRIMARY KEY (issuesnapshot_id, component_id), |
| 1230 | FOREIGN KEY (issuesnapshot_id) REFERENCES IssueSnapshot(id), |
| 1231 | FOREIGN KEY (component_id) REFERENCES ComponentDef(id) |
| 1232 | ) ENGINE=INNODB; |
| 1233 | |
| 1234 | CREATE TABLE IssueSnapshot2Label( |
| 1235 | issuesnapshot_id INT NOT NULL, |
| 1236 | label_id INT NOT NULL, |
| 1237 | |
| 1238 | PRIMARY KEY (issuesnapshot_id, label_id), |
| 1239 | FOREIGN KEY (issuesnapshot_id) REFERENCES IssueSnapshot(id), |
| 1240 | FOREIGN KEY (label_id) REFERENCES LabelDef(id) |
| 1241 | ) ENGINE=INNODB; |
| 1242 | |
| 1243 | CREATE TABLE IssueSnapshot2Cc( |
| 1244 | issuesnapshot_id INT NOT NULL, |
| 1245 | cc_id INT UNSIGNED NOT NULL, |
| 1246 | |
| 1247 | PRIMARY KEY (issuesnapshot_id, cc_id), |
| 1248 | FOREIGN KEY (issuesnapshot_id) REFERENCES IssueSnapshot(id), |
| 1249 | FOREIGN KEY (cc_id) REFERENCES User(user_id) |
| 1250 | ) ENGINE=INNODB; |
| 1251 | |
| 1252 | =============================================================== |
| 1253 | 2018-01-29: Add approval_id column to FieldDef table |
| 1254 | |
| 1255 | ALTER TABLE FieldDef ADD COLUMN approval_id INT; |
| 1256 | |
| 1257 | =============================================================== |
| 1258 | 2018-02-08: Drop previous approval tables and add default approvers table |
| 1259 | |
| 1260 | DROP TABLE ApprovalStatusDef; |
| 1261 | DROP TABLE Approval2Approver; |
| 1262 | DROP TABLE Issue2ApprovalValue; |
| 1263 | |
| 1264 | CREATE TABLE ApprovalDef2Approver ( |
| 1265 | approval_id INT NOT NULL, |
| 1266 | approver_id INT UNSIGNED NOT NULL, |
| 1267 | |
| 1268 | PRIMARY KEY (approval_id, approver_id), |
| 1269 | |
| 1270 | FOREIGN KEY (approval_id) REFERENCES FieldDef(id), |
| 1271 | FOREIGN KEY (approver_id) REFERENCES User(user_id) |
| 1272 | ) ENGINE=INNODB; |
| 1273 | |
| 1274 | ================================================================== |
| 1275 | 2018-02-09: Add project_id column to default approvers table |
| 1276 | |
| 1277 | ALTER TABLE ApprovalDef2Approver ADD project_id SMALLINT UNSIGNED NOT NULL; |
| 1278 | ALTER TABLE ApprovalDef2Approver ADD CONSTRAINT ApprovalDef2Approver_ibfk_3 FOREIGN KEY (project_id) REFERENCES Project(project_id); |
| 1279 | |
| 1280 | ================================================================== |
| 1281 | 2018-02-14: Expand IssueSnapshot time columns from INT to INT UNSIGNED |
| 1282 | ALTER TABLE IssueSnapshot MODIFY period_start INT UNSIGNED NOT NULL; |
| 1283 | ALTER TABLE IssueSnapshot MODIFY period_end INT UNSIGNED NOT NULL; |
| 1284 | |
| 1285 | |
| 1286 | ================================================================ |
| 1287 | 2018-02-22: Relax some constraints on issue snapshots |
| 1288 | |
| 1289 | ALTER TABLE IssueSnapshot MODIFY status_id int; |
| 1290 | ALTER TABLE IssueSnapshot DROP INDEX issue_id; |
| 1291 | ALTER TABLE IssueSnapshot ADD INDEX (`issue_id`,`period_start`,`period_end`); |
| 1292 | |
| 1293 | ================================================================ |
| 1294 | 2018-03-12: Add launch template milestones and approval tables |
| 1295 | |
| 1296 | CREATE TABLE Template2Milestone ( |
| 1297 | id INT NOT NULL AUTO_INCREMENT, |
| 1298 | template_id INT NOT NULL, |
| 1299 | name VARCHAR(255) BINARY NOT NULL, |
| 1300 | rank SMALLINT UNSIGNED, |
| 1301 | |
| 1302 | PRIMARY KEY (id, template_id), |
| 1303 | FOREIGN KEY (template_id) REFERENCES Template(id) |
| 1304 | ) ENGINE=INNODB; |
| 1305 | |
| 1306 | CREATE TABLE Template2ApprovalValue ( |
| 1307 | approval_id INT NOT NULL, |
| 1308 | template_id INT NOT NULL, |
| 1309 | milestone_id INT NOT NULL, |
| 1310 | launch_status ENUM ('NA', 'review_requested', 'started', 'need_info', 'approved', 'not_approved'), |
| 1311 | |
| 1312 | PRIMARY KEY (approval_id, template_id, milestone_id), |
| 1313 | |
| 1314 | FOREIGN KEY (approval_id) REFERENCES FieldDef(id), |
| 1315 | FOREIGN KEY (template_id) REFERENCES Template(id), |
| 1316 | FOREIGN KEY (milestone_id) REFERENCES Template2Milestone(id) |
| 1317 | ) ENGINE=INNODB; |
| 1318 | |
| 1319 | |
| 1320 | ================================================================ |
| 1321 | 2018-03-13: Edit approval state enum |
| 1322 | |
| 1323 | ALTER TABLE Template2ApprovalValue CHANGE launch_status status ENUM ( |
| 1324 | 'needs_review', 'na', 'review_requested', 'started', 'need_info', 'approved', 'not_approved'); |
| 1325 | |
| 1326 | |
| 1327 | ================================================================ |
| 1328 | 2018-03-14: Edit approval state enum *AGAIN* |
| 1329 | |
| 1330 | ALTER TABLE Template2ApprovalValue MODIFY status ENUM ( |
| 1331 | 'needs_review', 'na', 'review_requested', 'started', 'need_info', 'approved', 'not_approved', 'not_set'); |
| 1332 | |
| 1333 | |
| 1334 | ================================================================ |
| 1335 | 2018-03-15: Add Issue Approval and Mileston tables |
| 1336 | |
| 1337 | DROP TABLE IF EXISTS Approval2Approver; |
| 1338 | DROP TABLE IF EXISTS Issue2ApprovalValue; |
| 1339 | |
| 1340 | CREATE TABLE Issue2Milestone ( |
| 1341 | id INT NOT NULL AUTO_INCREMENT, |
| 1342 | issue_id INT NOT NULL, |
| 1343 | name VARCHAR(255) BINARY NOT NULL, |
| 1344 | rank SMALLINT UNSIGNED, |
| 1345 | |
| 1346 | PRIMARY KEY (id, issue_id), |
| 1347 | FOREIGN KEY (issue_id) REFERENCES Issue(id) |
| 1348 | ) ENGINE=INNODB; |
| 1349 | |
| 1350 | CREATE TABLE Issue2ApprovalValue ( |
| 1351 | issue_id INT NOT NULL, |
| 1352 | approval_id INT NOT NULL, |
| 1353 | milestone_id INT NOT NULL, |
| 1354 | status ENUM ('needs_review', 'na', 'review_requested', 'started', 'need_info', 'approved', 'not_approved', 'not_set') DEFAULT 'not_set' NOT NULL, |
| 1355 | setter_id INT UNSIGNED, |
| 1356 | set_on INT, |
| 1357 | |
| 1358 | PRIMARY KEY (issue_id, approval_id, milestone_id), |
| 1359 | FOREIGN KEY (issue_id) REFERENCES Issue(id), |
| 1360 | FOREIGN KEY (approval_id) REFERENCES FieldDef(id), |
| 1361 | FOREIGN KEY (milestone_id) REFERENCES Issue2Milestone(id), |
| 1362 | FOREIGN KEY (setter_id) REFERENCES User(user_id) |
| 1363 | ) ENGINE=INNODB; |
| 1364 | |
| 1365 | CREATE TABLE IssueApproval2Approvers ( |
| 1366 | issue_id INT NOT NULL, |
| 1367 | approval_id INT NOT NULL, |
| 1368 | approver_id INT UNSIGNED NOT NULL, |
| 1369 | |
| 1370 | PRIMARY KEY (issue_id, approval_id, approver_id), |
| 1371 | FOREIGN KEY (issue_id) REFERENCES Issue(id), |
| 1372 | FOREIGN KEY (approval_id) REFERENCES FieldDef(id), |
| 1373 | FOREIGN KEY (approver_id) REFERENCES User(user_id) |
| 1374 | ) ENGINE=INNODB; |
| 1375 | |
| 1376 | ALTER TABLE Template2ApprovalValue MODIFY status ENUM ( |
| 1377 | 'needs_review', 'na', 'review_requested', 'started', 'need_info', 'approved', 'not_approved', 'not_set') DEFAULT 'not_set' NOT NULL; |
| 1378 | |
| 1379 | ================================================================ |
| 1380 | 2018-03-15: Soft-delete Hotlists. |
| 1381 | ALTER TABLE Hotlist ADD COLUMN is_deleted BOOLEAN DEFAULT FALSE; |
| 1382 | |
| 1383 | =============================================================== |
| 1384 | 2018-03-19: Rename issue approvers table. |
| 1385 | |
| 1386 | RENAME TABLE IssueApproval2Approvers TO IssueApproval2Approver; |
| 1387 | |
| 1388 | ================================================================ |
| 1389 | 2018-03-22: Add Hotlist support to IssueSnapshots. |
| 1390 | |
| 1391 | CREATE TABLE IssueSnapshot2Hotlist( |
| 1392 | issuesnapshot_id INT NOT NULL, |
| 1393 | hotlist_id INT UNSIGNED NOT NULL, |
| 1394 | |
| 1395 | PRIMARY KEY (issuesnapshot_id, hotlist_id), |
| 1396 | FOREIGN KEY (issuesnapshot_id) REFERENCES IssueSnapshot(id), |
| 1397 | FOREIGN KEY (hotlist_id) REFERENCES Hotlist(id) |
| 1398 | ) ENGINE=INNODB; |
| 1399 | |
| 1400 | ================================================================ |
| 1401 | 2018-03-23: Add ApprovalDef2Survey table. |
| 1402 | |
| 1403 | CREATE TABLE ApprovalDef2Survey ( |
| 1404 | approval_id INT NOT NULL, |
| 1405 | survey TEXT, |
| 1406 | project_id SMALLINT UNSIGNED NOT NULL, |
| 1407 | |
| 1408 | PRIMARY KEY (approval_id, project_id), |
| 1409 | |
| 1410 | FOREIGN KEY (approval_id) REFERENCES FieldDef(id), |
| 1411 | FOREIGN KEY (project_id) REFERENCES Project(project_id) |
| 1412 | ) ENGINE=INNODB; |
| 1413 | |
| 1414 | =============================================================== |
| 1415 | 2018-03-24: Add IssueApproval2Comment table. |
| 1416 | |
| 1417 | CREATE TABLE IssueApproval2Comment ( |
| 1418 | approval_id INT NOT NULL, |
| 1419 | comment_id INT NOT NULL, |
| 1420 | |
| 1421 | PRIMARY KEY (comment_id), |
| 1422 | INDEX (approval_id), |
| 1423 | FOREIGN KEY (approval_id) REFERENCES FieldDef(id), |
| 1424 | FOREIGN KEY (comment_id) REFERENCES Comment(id) |
| 1425 | ) ENGINE=INNODB; |
| 1426 | |
| 1427 | =============================================================== |
| 1428 | 2018-03-29: Rename Milestones to Phases. |
| 1429 | |
| 1430 | CREATE TABLE Issue2Phase ( |
| 1431 | id INT NOT NULL AUTO_INCREMENT, |
| 1432 | issue_id INT NOT NULL, |
| 1433 | name VARCHAR(255) BINARY NOT NULL, |
| 1434 | rank SMALLINT UNSIGNED, |
| 1435 | |
| 1436 | PRIMARY KEY (id, issue_id), |
| 1437 | FOREIGN KEY (issue_id) REFERENCES Issue(id) |
| 1438 | ) ENGINE=INNODB; |
| 1439 | |
| 1440 | CREATE TABLE Template2Phase ( |
| 1441 | id INT NOT NULL AUTO_INCREMENT, |
| 1442 | template_id INT NOT NULL, |
| 1443 | name VARCHAR(255) BINARY NOT NULL, |
| 1444 | rank SMALLINT UNSIGNED, |
| 1445 | |
| 1446 | PRIMARY KEY (id, template_id), |
| 1447 | FOREIGN KEY (template_id) REFERENCES Template(id) |
| 1448 | ) ENGINE=INNODB; |
| 1449 | |
| 1450 | ALTER TABLE Issue2ApprovalValue DROP FOREIGN KEY Issue2ApprovalValue_ibfk_4; |
| 1451 | ALTER TABLE Issue2ApprovalValue ADD COLUMN phase_id int NOT NULL; |
| 1452 | CREATE INDEX IF NOT EXISTS phase_id ON Issue2ApprovalValue (phase_id); |
| 1453 | ALTER TABLE Issue2ApprovalValue ADD FOREIGN KEY (phase_id) REFERENCES Issue2Phase(id); |
| 1454 | |
| 1455 | ALTER TABLE Template2ApprovalValue DROP FOREIGN KEY Template2ApprovalValue_ibfk_3; |
| 1456 | ALTER TABLE Template2ApprovalValue ADD COLUMN phase_id int NOT NULL; |
| 1457 | CREATE INDEX IF NOT EXISTS phase_id ON Template2ApprovalValue (phase_id); |
| 1458 | ALTER TABLE Template2ApprovalValue ADD FOREIGN KEY (phase_id) REFERENCES Template2Phase(id); |
| 1459 | |
| 1460 | ================================================================ |
| 1461 | 2018-04-18: Drop all milestone schema. |
| 1462 | |
| 1463 | ALTER TABLE Template2ApprovalValue DROP COLUMN milestone_id; |
| 1464 | ALTER TABLE Issue2ApprovalValue DROP COLUMN milestone_id; |
| 1465 | |
| 1466 | DROP TABLE Template2Milestone; |
| 1467 | DROP TABLE Issue2Milestone; |
| 1468 | |
| 1469 | ================================================================ |
| 1470 | 2018-04-25: Add phase_id to X2ApprovalValue tables' primary keys. |
| 1471 | |
| 1472 | ALTER TABLE Template2ApprovalValue DROP PRIMARY KEY, ADD PRIMARY KEY(approval_id, template_id, phase_id); |
| 1473 | ALTER TABLE Issue2ApprovalValue DROP PRIMARY KEY, ADD PRIMARY KEY(issue_id, approval_id, phase_id); |
| 1474 | |
| 1475 | ================================================================== |
| 1476 | 2018-04-30: Rename Issue2Phase table to IssuePhaseDef: Part One |
| 1477 | |
| 1478 | CREATE TABLE IssuePhaseDef ( |
| 1479 | id INT NOT NULL AUTO_INCREMENT, |
| 1480 | name VARCHAR(255) BINARY NOT NULL, |
| 1481 | rank SMALLINT UNSIGNED, |
| 1482 | |
| 1483 | PRIMARY KEY (id) |
| 1484 | ) ENGINE=INNODB; |
| 1485 | |
| 1486 | ALTER TABLE Issue2ApprovalValue DROP FOREIGN KEY Issue2ApprovalValue_ibfk_4; |
| 1487 | ALTER TABLE Issue2ApprovalValue ADD FOREIGN KEY (phase_id) REFERENCES IssuePhaseDef(id); |
| 1488 | |
| 1489 | ================================================================== |
| 1490 | 2018-05-02: Add phase_id to Issue2FieldValue table. |
| 1491 | |
| 1492 | ALTER TABLE Issue2FieldValue ADD COLUMN phase_id INT; |
| 1493 | ALTER TABLE Issue2FieldValue ADD FOREIGN KEY (phase_id) REFERENCES IssuePhaseDef(id); |
| 1494 | |
| 1495 | =================================================================== |
| 1496 | 2018-5-01: Add is_phase_field to FieldDef. |
| 1497 | |
| 1498 | ALTER TABLE FieldDef ADD COLUMN is_phase_field BOOLEAN DEFAULT FALSE; |
| 1499 | |
| 1500 | =================================================================== |
| 1501 | 2018-5-11: Rename Issue2Phase table to IssuePhaseDef: Part Two, drop Issue2Phase |
| 1502 | |
| 1503 | DROP TABLE Issue2Phase; |
| 1504 | ================================================================== |
| 1505 | 2018-05-11: Restrict size of index field in Issue2FieldValue |
| 1506 | |
| 1507 | ALTER TABLE Issue2FieldValue DROP INDEX field_id_5; |
| 1508 | ALTER TABLE Issue2FieldValue ADD INDEX (field_id, issue_shard, url_value(255)); |
| 1509 | |
| 1510 | ================================================================== |
| 1511 | 2018-05-18: Replace Template2Phase FK with IssuePhaseDef. |
| 1512 | |
| 1513 | TRUNCATE TABLE Template2ApprovalValue; |
| 1514 | ALTER TABLE Template2ApprovalValue DROP FOREIGN KEY Template2ApprovalValue_ibfk_3; |
| 1515 | ALTER TABLE Template2ApprovalValue ADD FOREIGN KEY (phase_id) REFERENCES IssuePhaseDef(id); |
| 1516 | |
| 1517 | ================================================================ |
| 1518 | 2018-05-22: Add boolean columns to control autocomplete exclusions. |
| 1519 | |
| 1520 | ALTER TABLE AutocompleteExclusion |
| 1521 | ADD COLUMN ac_exclude BOOLEAN DEFAULT TRUE, |
| 1522 | ADD COLUMN no_expand BOOLEAN DEFAULT FALSE; |
| 1523 | |
| 1524 | ================================================================== |
| 1525 | 2018-05-30: Add comment to Invalidate table |
| 1526 | |
| 1527 | ALTER TABLE Invalidate CHANGE kind |
| 1528 | kind ENUM('user', 'project', 'issue', 'issue_id', 'hotlist', |
| 1529 | 'comment'); |
| 1530 | |
| 1531 | ================================================================= |
| 1532 | 2018-06-05: Drop Template2Phase tbl and NOT NULL constraint for approval value phase_id columns. |
| 1533 | |
| 1534 | DROP TABLE Template2Phase; |
| 1535 | |
| 1536 | ALTER TABLE Issue2ApprovalValue DROP PRIMARY KEY, ADD PRIMARY KEY(issue_id, approval_id); |
| 1537 | ALTER TABLE Issue2ApprovalValue MODIFY COLUMN phase_id INT; |
| 1538 | |
| 1539 | ALTER TABLE Template2ApprovalValue DROP PRIMARY KEY, ADD PRIMARY KEY(approval_id, template_id); |
| 1540 | ALTER TABLE Template2ApprovalValue MODIFY COLUMN phase_id INT; |
| 1541 | |
| 1542 | ================================================================= |
| 1543 | 2018-06-22: Add 'template' to Invalidate.kind_enum |
| 1544 | |
| 1545 | ALTER TABLE Invalidate MODIFY COLUMN kind enum('user', 'project', 'issue', 'issue_id', 'hotlist', 'comment', 'template') NOT NULL; |
| 1546 | |
| 1547 | ================================================================= |
| 1548 | 2018-07-02: Add UserCommits table to keep track of commits. |
| 1549 | |
| 1550 | CREATE TABLE UserCommits ( |
| 1551 | commit_sha VARCHAR(40), |
| 1552 | parent_sha VARCHAR(40), |
| 1553 | author_id INT UNSIGNED NOT NULL, |
| 1554 | commit_time INT NOT NULL, |
| 1555 | commit_message TEXT, |
| 1556 | commit_repo VARCHAR(255), |
| 1557 | |
| 1558 | PRIMARY KEY (commit_sha), |
| 1559 | INDEX (author_id, commit_time), |
| 1560 | INDEX (commit_time) |
| 1561 | ) ENGINE=INNODB; |
| 1562 | |
| 1563 | |
| 1564 | ================================================================= |
| 1565 | 2018-07-16: Drop parent_sha because it isn't needed in this table and give commit_repo a clearer name. |
| 1566 | |
| 1567 | ALTER TABLE UserCommits DROP COLUMN parent_sha; |
| 1568 | ALTER TABLE UserCommits CHANGE commit_repo commit_repo_url VARCHAR(255); |
| 1569 | |
| 1570 | |
| 1571 | ================================================================ |
| 1572 | 2018-08-27: Allow computed external user groups, e.g., everyone@google.com. |
| 1573 | |
| 1574 | ALTER TABLE UserGroupSettings |
| 1575 | MODIFY COLUMN |
| 1576 | external_group_type ENUM ('chrome_infra_auth', 'mdb', 'baggins', 'computed'); |
| 1577 | |
| 1578 | |
| 1579 | ================================================================ |
| 1580 | 2018-09-24: Add 'usergroup to Invalidate.kind enum |
| 1581 | |
| 1582 | ALTER TABLE Invalidate MODIFY COLUMN kind enum( |
| 1583 | 'user', 'usergroup', 'project', 'issue', 'issue_id', |
| 1584 | 'hotlist', 'comment', 'template') NOT NULL; |
| 1585 | |
| 1586 | ================================================================ |
| 1587 | 2018-10-30: Fix ApprovalValue status enum for 'review_started' |
| 1588 | |
| 1589 | ALTER TABLE Template2ApprovalValue MODIFY status ENUM ( |
| 1590 | 'needs_review', 'na', 'review_requested', 'review_started', 'need_info', 'approved', 'not_approved', 'not_set') DEFAULT 'not_set' NOT NULL; |
| 1591 | |
| 1592 | ALTER TABLE Issue2ApprovalValue MODIFY status ENUM ( |
| 1593 | 'needs_review', 'na', 'review_requested', 'review_started', 'need_info', 'approved', 'not_approved', 'not_set') DEFAULT 'not_set' NOT NULL; |
| 1594 | |
| 1595 | |
| 1596 | ================================================================ |
| 1597 | 2018-11-02: Redo LinkedAccount table. |
| 1598 | |
| 1599 | DROP TABLE LinkedAccount; |
| 1600 | CREATE TABLE LinkedAccount ( |
| 1601 | parent_id INT UNSIGNED NOT NULL, |
| 1602 | child_id INT UNSIGNED NOT NULL, |
| 1603 | |
| 1604 | KEY (parent_id), |
| 1605 | UNIQUE KEY (child_id), |
| 1606 | FOREIGN KEY (parent_id) REFERENCES User(user_id), |
| 1607 | FOREIGN KEY (child_id) REFERENCES User(user_id) |
| 1608 | ) ENGINE=INNODB; |
| 1609 | |
| 1610 | ================================================================ |
| 1611 | 2018-12-03: Create LinkedAccountInvite table. |
| 1612 | |
| 1613 | CREATE TABLE LinkedAccountInvite ( |
| 1614 | parent_id INT UNSIGNED NOT NULL, |
| 1615 | child_id INT UNSIGNED NOT NULL, |
| 1616 | |
| 1617 | KEY (parent_id), |
| 1618 | UNIQUE KEY (child_id), |
| 1619 | FOREIGN KEY (parent_id) REFERENCES User(user_id), |
| 1620 | FOREIGN KEY (child_id) REFERENCES User(user_id) |
| 1621 | ) ENGINE=INNODB; |
| 1622 | |
| 1623 | ================================================================================== |
| 1624 | 2018-1-15: Add notify_group and notify_members bool col to UserGroupSettings table. |
| 1625 | |
| 1626 | ALTER TABLE UserGroupSettings ADD COLUMN notify_members BOOLEAN DEFAULT TRUE; |
| 1627 | ALTER TABLE UserGroupSettings ADD COLUMN notify_group BOOLEAN DEFAULT FALSE; |
| 1628 | |
| 1629 | ================================================================= |
| 1630 | 2019-01-23: Add two new indexes to IssueSnapshot for performance. |
| 1631 | |
| 1632 | CREATE INDEX by_period_start ON IssueSnapshot (shard, project_id, status_id, period_start); |
| 1633 | CREATE INDEX by_period_end ON IssueSnapshot (shard, project_id, status_id, period_end); |
| 1634 | |
| 1635 | |
| 1636 | ================================================================ |
| 1637 | 2019-01-25: Start a more flexible way of storing user preferences. |
| 1638 | |
| 1639 | CREATE TABLE UserPrefs ( |
| 1640 | user_id INT UNSIGNED NOT NULL, |
| 1641 | name VARCHAR(40), |
| 1642 | value VARCHAR(80), |
| 1643 | |
| 1644 | UNIQUE KEY (user_id, name) |
| 1645 | ) ENGINE=INNODB; |
| 1646 | |
| 1647 | ================================================================ |
| 1648 | 2019-04-10: Set UserPrefs that indicate that privacy click-through was seen. |
| 1649 | This is part of phasing out DismissedCues. |
| 1650 | |
| 1651 | INSERT IGNORE INTO UserPrefs (user_id, name, value) |
| 1652 | SELECT user_id, cue, 'true' |
| 1653 | FROM DismissedCues; |
| 1654 | |
| 1655 | ================================================================ |
| 1656 | 2019-05-13: Drop unused ActionLimit table. |
| 1657 | |
| 1658 | DROP TABLE ActionLimit; |
| 1659 | |
| 1660 | ================================================================ |
| 1661 | 2019-05-24: Add ext_issue_identifier column to DanglingIssueRelation table. |
| 1662 | |
| 1663 | ALTER TABLE DanglingIssueRelation ADD COLUMN ext_issue_identifier VARCHAR(2048); |
| 1664 | ALTER TABLE DanglingIssueRelation ADD INDEX (ext_issue_identifier); |
| 1665 | |
| 1666 | ================================================================ |
| 1667 | 2019-06-06: Allow full unicode labels. |
| 1668 | |
| 1669 | ALTER TABLE LabelDef CHANGE label label VARCHAR(80) BINARY NOT NULL COLLATE utf8mb4_unicode_ci; |
| 1670 | |
| 1671 | ================================================================ |
| 1672 | 2019-06-07: Add indexes to reduce cases of using filesort |
| 1673 | |
| 1674 | ALTER TABLE HotlistVisitHistory ADD INDEX (user_id, viewed); |
| 1675 | ALTER TABLE ReindexQueue ADD INDEX (created); |
| 1676 | |
| 1677 | ================================================================ |
| 1678 | 2019-06-13: Add ext_issue_identifier to DanglingIssueRelation PRIMARY KEY. |
| 1679 | |
| 1680 | ALTER TABLE DanglingIssueRelation MODIFY COLUMN ext_issue_identifier VARCHAR(255); |
| 1681 | ALTER TABLE DanglingIssueRelation DROP PRIMARY KEY, ADD PRIMARY KEY(issue_id, dst_issue_project, dst_issue_local_id, kind, ext_issue_identifier); |
| 1682 | |
| 1683 | ================================================================ |
| 1684 | 2019-06-25: Add unique constraint on SpamReport. |
| 1685 | |
| 1686 | ALTER IGNORE TABLE SpamReport ADD UNIQUE (user_id, comment_id, issue_id); |
| 1687 | |
| 1688 | ================================================================ |
| 1689 | 2019-07-03: Add CommentImporter table. |
| 1690 | |
| 1691 | CREATE TABLE CommentImporter ( |
| 1692 | comment_id INT NOT NULL, |
| 1693 | importer_id INT UNSIGNED NOT NULL, |
| 1694 | |
| 1695 | PRIMARY KEY (comment_id), |
| 1696 | FOREIGN KEY (comment_id) REFERENCES Comment(id), |
| 1697 | FOREIGN KEY (importer_id) REFERENCES User(user_id) |
| 1698 | ) ENGINE=INNODB; |
| 1699 | |
| 1700 | |
| 1701 | ================================================================ |
| 1702 | 2019-10-09: Drop DismissedCues because that data has been in UserPrefs since April. |
| 1703 | |
| 1704 | DROP TABLE DismissedCues; |
| 1705 | |
| 1706 | ================================================================ |
| 1707 | 2019-10-24: Insert row representing deleted user. |
| 1708 | |
| 1709 | INSERT IGNORE INTO User (user_id, email) VALUES (1, ''); |
| 1710 | |
| 1711 | ================================================================== |
| 1712 | 2019-11-21: Add hotlist_id to Invalidate table. |
| 1713 | |
| 1714 | ALTER TABLE Invalidate CHANGE kind |
| 1715 | kind ENUM('user', 'usergroup', 'project', 'issue', 'issue_id', 'hotlist', 'comment', 'template', 'hotlist_id'); |
| 1716 | |
| 1717 | |
| 1718 | ================================================================ |
| 1719 | 2019-12-30: Set custom revision_url_format for pigweed project. |
| 1720 | |
| 1721 | UPDATE Project SET revision_url_format = 'https://pigweed-review.git.corp.google.com/q/{revnum}' WHERE project_name='pigweed'; |
| 1722 | |
| 1723 | ================================================================ |
| 1724 | 2020-02-19: Create table for editors of a field. Also, add column in FieldDef |
| 1725 | to indicate if the editors of that field are being restricted. |
| 1726 | |
| 1727 | CREATE TABLE FieldDef2Editor ( |
| 1728 | field_id INT NOT NULL, |
| 1729 | editor_id INT UNSIGNED NOT NULL, |
| 1730 | |
| 1731 | PRIMARY KEY (field_id, editor_id), |
| 1732 | FOREIGN KEY (field_id) REFERENCES FieldDef(id), |
| 1733 | FOREIGN KEY (editor_id) REFERENCES User(user_id) |
| 1734 | ) ENGINE=INNODB; |
| 1735 | |
| 1736 | |
| 1737 | ALTER TABLE FieldDef ADD COLUMN is_restricted_field BOOL DEFAULT FALSE; |
| 1738 | |
| 1739 | ================================================================ |
| 1740 | 2020-05-14: Add option to force detailed notifications for projects. |
| 1741 | |
| 1742 | ALTER TABLE Project ADD COLUMN issue_notify_always_detailed BOOLEAN DEFAULT FALSE; |
| 1743 | |
Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 1744 | ================================================================ |
| 1745 | 2022-12-27: Added more IssueUpdate fields. |
| 1746 | |
| 1747 | ALTER TABLE IssueUpdate ADD COLUMN added_component_id VARCHAR(80); |
| 1748 | ALTER TABLE IssueUpdate ADD COLUMN removed_component_id VARCHAR(80); |
| 1749 | |
| 1750 | ================================================================ |
| 1751 | 2023-09-11: Add new modified timestamp. See: go/monorail-enhanced-modified-time |
| 1752 | |
| 1753 | ALTER TABLE Issue ADD COLUMN migration_modified INT; |