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