blob: 26c21dd8f5ca02f117faed9b73988bb95812056c [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001# 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
6This file contains a log of ALTER TABLE statements that need to be executed
7to bring a Monorail SQL database up to the current schema.
8
9================================================================
102012-05-24: Added more Project fields.
11
12ALTER TABLE Project ADD COLUMN read_only_reason VARCHAR(80);
13ALTER TABLE Project ADD COLUMN issue_notify_address VARCHAR(80);
14ALTER TABLE Project ADD COLUMN attachment_bytes_used INT DEFAULT 0;
15ALTER TABLE Project ADD COLUMN attachment_quota INT DEFAULT 52428800;
16ALTER TABLE Project ADD COLUMN moved_to VARCHAR(250);
17ALTER TABLE Project ADD COLUMN process_inbound_email BOOLEAN DEFAULT FALSE;
18
19================================================================
202012-06-01: Added inbound_message for issue comments
21
22ALTER TABLE Comment ADD COLUMN inbound_message TEXT;
23
24
25================================================================
262012-06-05: Removed send_notifications_from_user because Monorail will
27not offer that feature any time soon.
28
29ALTER TABLE ProjectIssueConfig DROP COLUMN send_notifications_from_user;
30
31
32================================================================
332012-06-05: Add initial subscription options.
34
35ALTER TABLE User2SavedQuery ADD COLUMN subscription_mode
36 ENUM ('noemail', 'immediate') DEFAULT 'noemail' NOT NULL;
37
38
39================================================================
402012-07-02: Revised project states and added state_reason and delete_time
41
42ALTER TABLE Project MODIFY COLUMN state ENUM ('live', 'archived', 'deletable')
43NOT NULL;
44
45ALTER TABLE Project ADD COLUMN state_reason VARCHAR(80);
46ALTER TABLE Project ADD COLUMN delete_time INT;
47
48
49================================================================
502012-07-05: Added action limits and dismissed cues
51
52CREATE 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
66CREATE 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
74ALTER TABLE User ADD COLUMN ignore_action_limits BOOLEAN DEFAULT FALSE;
75
76================================================================
772012-07-11: No longer using Counter table.
78
79DROP TABLE Counter;
80
81================================================================
822012-09-06: Drop AttachmentContent, put blobkey in Attachment
83and drop some redundant columns.
84
85Note: This loses attachment data that might currently be in your
86instance. Good thing these schema refinements are getting done
87before launch.
88
89ALTER TABLE Attachment DROP COLUMN attachment_id;
90ALTER TABLE Attachment DROP COLUMN comment_created;
91ALTER TABLE Attachment ADD COLUMN blobkey VARCHAR(1024) NOT NULL;
92
93DROP TABLE AttachmentContent;
94
95ALTER TABLE IssueUpdate DROP COLUMN comment_created;
96
97
98================================================================
992012-11-01: Add Components to IssueUpdate enum.
100
101alter table IssueUpdate modify field ENUM ('summary', 'status', 'owner',
102'cc', 'labels', 'blockedon', 'blocking', 'mergedinto', 'project',
103'components') NOT NULL;
104
105
106================================================================
1072012-12-10: Add template admins and field admins
108
109
110CREATE 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
119CREATE 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================================================================
1302012-12-14: Add a table of custom field values
131
132ALTER TABLE FieldDef MODIFY field_type ENUM (
133 'enum_type', 'int_type', 'str_type', 'user_type') NOT NULL;
134
135CREATE 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================================================================
1572012-12-18: persistence for update objects on custom fields
158
159ALTER TABLE IssueUpdate MODIFY field ENUM (
160 'summary', 'status', 'owner', 'cc', 'labels', 'blockedon', 'blocking', 'mergedinto',
161 'project', 'components', 'custom' ) NOT NULL;
162
163ALTER TABLE IssueUpdate ADD custom_field_name VARCHAR(255);
164
165
166================================================================
1672012-12-27: Rename component owner to component admin
168
169DROP TABLE Component2Owner;
170
171CREATE 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================================================================
1832013-01-20: add field applicability predicate
184
185ALTER TABLE FieldDef ADD applicable_type VARCHAR(80);
186ALTER TABLE FieldDef ADD applicable_predicate TEXT;
187
188================================================================
1892013-01-25: add field validation details
190
191ALTER TABLE FieldDef ADD max_value INT;
192ALTER TABLE FieldDef ADD min_value INT;
193ALTER TABLE FieldDef ADD regex VARCHAR(80);
194ALTER TABLE FieldDef ADD needs_member BOOLEAN;
195ALTER TABLE FieldDef ADD needs_perm VARCHAR(80);
196
197
198================================================================
1992013-02-11: add grant and notify to user-valued fields
200
201ALTER TABLE FieldDef ADD grants_perm VARCHAR(80);
202ALTER TABLE FieldDef ADD notify_on ENUM ('never', 'any_comment') DEFAULT 'never' NOT NULL;
203
204
205================================================================
2062013-03-17: Add Template2FieldValue
207
208CREATE 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================================================================
2252013-05-08: eliminated same_org_only
226
227-- This needs to be done on all shards.
228UPDATE Project SET access = 'members_only' WHERE access = 'same_org_only';
229ALTER TABLE Project MODIFY COLUMN access ENUM ('anyone', 'members_only');
230
231================================================================
2322013-05-08: implemented recent activity timestamp
233
234-- This needs to be done on all shards.
235ALTER TABLE Project ADD recent_activity_timestamp INT;
236
237================================================================
2382013-07-01: use BIGINT for Invalidate timesteps
239
240ALTER TABLE Invalidate MODIFY COLUMN timestep BIGINT NOT NULL AUTO_INCREMENT;
241
242
243================================================================
2442013-07-23: renamed to avoid "participant"
245
246RENAME TABLE ParticipantDuty TO MemberDuty;
247RENAME TABLE ParticipantNotes TO MemberNotes;
248
249================================================================
2502013-08-22: renamed issue_id to local_id
251
252-- On primary and all shards
253ALTER TABLE Issue CHANGE issue_id local_id INT NOT NULL;
254
255-- On primary only
256ALTER TABLE IssueFormerLocations CHANGE issue_id local_id INT NOT NULL;
257
258================================================================
2592013-08-24: renamed iid to issue_id
260
261-- On primary and all shards
262
263ALTER TABLE IssueSummary DROP FOREIGN KEY IssueSummary_ibfk_1;
264ALTER TABLE IssueSummary CHANGE iid issue_id INT NOT NULL;
265ALTER TABLE IssueSummary ADD FOREIGN KEY (issue_id) REFERENCES Issue(id);
266
267ALTER TABLE Issue2Label DROP FOREIGN KEY Issue2Label_ibfk_1;
268ALTER TABLE Issue2Label CHANGE iid issue_id INT NOT NULL;
269ALTER TABLE Issue2Label ADD FOREIGN KEY (issue_id) REFERENCES Issue(id);
270
271ALTER TABLE Issue2Component DROP FOREIGN KEY Issue2Component_ibfk_1;
272ALTER TABLE Issue2Component CHANGE iid issue_id INT NOT NULL;
273ALTER TABLE Issue2Component ADD FOREIGN KEY (issue_id) REFERENCES Issue(id);
274
275ALTER TABLE Issue2Cc DROP FOREIGN KEY Issue2Cc_ibfk_1;
276ALTER TABLE Issue2Cc CHANGE iid issue_id INT NOT NULL;
277ALTER TABLE Issue2Cc ADD FOREIGN KEY (issue_id) REFERENCES Issue(id);
278
279ALTER TABLE Issue2Notify DROP FOREIGN KEY Issue2Notify_ibfk_1;
280ALTER TABLE Issue2Notify CHANGE iid issue_id INT NOT NULL;
281ALTER TABLE Issue2Notify ADD FOREIGN KEY (issue_id) REFERENCES Issue(id);
282
283ALTER TABLE IssueStar DROP FOREIGN KEY IssueStar_ibfk_1;
284ALTER TABLE IssueStar CHANGE iid issue_id INT NOT NULL;
285ALTER TABLE IssueStar ADD FOREIGN KEY (issue_id) REFERENCES Issue(id);
286
287ALTER TABLE IssueRelation DROP FOREIGN KEY IssueRelation_ibfk_1;
288ALTER TABLE IssueRelation CHANGE iid issue_id INT NOT NULL;
289ALTER TABLE IssueRelation ADD FOREIGN KEY (issue_id) REFERENCES Issue(id);
290
291ALTER TABLE IssueRelation CHANGE dst_iid dst_issue_id INT NOT NULL;
292
293ALTER TABLE Issue2FieldValue DROP FOREIGN KEY Issue2FieldValue_ibfk_1;
294ALTER TABLE Issue2FieldValue CHANGE iid issue_id INT NOT NULL;
295ALTER TABLE Issue2FieldValue ADD FOREIGN KEY (issue_id) REFERENCES Issue(id);
296
297-- On primary only
298ALTER TABLE Comment DROP FOREIGN KEY Comment_ibfk_2;
299ALTER TABLE Comment CHANGE iid issue_id INT NOT NULL;
300ALTER TABLE Comment ADD FOREIGN KEY (issue_id) REFERENCES Issue(id);
301
302ALTER TABLE Attachment DROP FOREIGN KEY Attachment_ibfk_1;
303ALTER TABLE Attachment CHANGE iid issue_id INT NOT NULL;
304ALTER TABLE Attachment ADD FOREIGN KEY (issue_id) REFERENCES Issue(id);
305
306ALTER TABLE IssueUpdate DROP FOREIGN KEY IssueUpdate_ibfk_1;
307ALTER TABLE IssueUpdate CHANGE iid issue_id INT NOT NULL;
308ALTER TABLE IssueUpdate ADD FOREIGN KEY (issue_id) REFERENCES Issue(id);
309
310-- I was missing a foreign key constraint here. Adding now.
311ALTER TABLE IssueFormerLocations CHANGE iid issue_id INT NOT NULL;
312ALTER TABLE IssueFormerLocations ADD FOREIGN KEY (issue_id) REFERENCES Issue(id);
313
314-- I was missing a foreign key constraint here. Adding now.
315ALTER TABLE ReindexQueue CHANGE iid issue_id INT NOT NULL;
316ALTER TABLE ReindexQueue ADD FOREIGN KEY (issue_id) REFERENCES Issue(id);
317
318
319================================================================
3202013-08-30: added per-project email sending flag
321
322-- On primary and all shards
323ALTER TABLE Project ADD COLUMN deliver_outbound_email BOOLEAN DEFAULT FALSE;
324
325
326================================================================
3272013-10-30: renamed prompts to templates
328
329ALTER TABLE ProjectIssueConfig
330CHANGE default_prompt_for_developers default_template_for_developers INT NOT NULL;
331
332ALTER TABLE ProjectIssueConfig
333CHANGE default_prompt_for_users default_template_for_users INT NOT NULL;
334
335ALTER TABLE Template
336CHANGE prompt_name name VARCHAR(255) NOT NULL,
337CHANGE prompt_text content TEXT,
338CHANGE prompt_summary summary TEXT,
339CHANGE prompt_summary_must_be_edited summary_must_be_edited BOOLEAN,
340CHANGE prompt_owner_id owner_id INT,
341CHANGE prompt_status status VARCHAR(255),
342CHANGE prompt_members_only members_only BOOLEAN;
343
344
345================================================================
3462013-11-18: add LocalIDCounter to primary DB only, and fill in values.
347
348CREATE 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.
359REPLACE INTO LocalIDCounter
360SELECT project_id, MAX(local_id)
361FROM Issue
362GROUP BY project_id;
363
364================================================================
3652015-06-12: add issue_id to Invalidate's enum for kind.
366
367ALTER TABLE Invalidate CHANGE kind kind ENUM('user', 'project', 'issue', 'issue_id');
368
369================================================================
3702015-07-24: Rename blobkey to gcs_object_id because we are using
371Google Cloud storage now.
372
373ALTER TABLE Attachment CHANGE blobkey gcs_object_id VARCHAR(1024) NOT NULL;
374
375===============================================================
3762015-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
381ALTER TABLE User2Project DROP FOREIGN KEY user2project_ibfk_2;
382ALTER TABLE ExtraPerm DROP FOREIGN KEY extraperm_ibfk_2;
383ALTER TABLE MemberNotes DROP FOREIGN KEY membernotes_ibfk_2;
384ALTER TABLE UserStar DROP FOREIGN KEY userstar_ibfk_1;
385ALTER TABLE UserStar DROP FOREIGN KEY userstar_ibfk_2;
386ALTER TABLE ProjectStar DROP FOREIGN KEY projectstar_ibfk_1;
387ALTER TABLE UserGroup DROP FOREIGN KEY usergroup_ibfk_1;
388ALTER TABLE UserGroup DROP FOREIGN KEY usergroup_ibfk_2;
389ALTER TABLE UserGroupSettings DROP FOREIGN KEY usergroupsettings_ibfk_1;
390ALTER TABLE QuickEditHistory DROP FOREIGN KEY quickedithistory_ibfk_2;
391ALTER TABLE QuickEditMostRecent DROP FOREIGN KEY quickeditmostrecent_ibfk_2;
392ALTER TABLE Issue DROP FOREIGN KEY issue_ibfk_2;
393ALTER TABLE Issue DROP FOREIGN KEY issue_ibfk_3;
394ALTER TABLE Issue DROP FOREIGN KEY issue_ibfk_4;
395ALTER TABLE Issue2Cc DROP FOREIGN KEY issue2cc_ibfk_2;
396ALTER TABLE IssueStar DROP FOREIGN KEY issuestar_ibfk_1; -- ?
397ALTER TABLE Issue2FieldValue DROP FOREIGN KEY issue2fieldvalue_ibfk_2;
398ALTER TABLE Comment DROP FOREIGN KEY comment_ibfk_3;
399ALTER TABLE Comment DROP FOREIGN KEY comment_ibfk_4;
400ALTER TABLE FieldDef2Admin DROP FOREIGN KEY fielddef2admin_ibfk_2;
401ALTER TABLE Template2Admin DROP FOREIGN KEY template2admin_ibfk_2;
402ALTER TABLE Template2FieldValue DROP FOREIGN KEY template2fieldvalue_ibfk_2;
403ALTER TABLE Component2Admin DROP FOREIGN KEY component2admin_ibfk_2;
404ALTER TABLE Component2Cc DROP FOREIGN KEY component2cc_ibfk_2;
405ALTER TABLE User2SavedQuery DROP FOREIGN KEY user2savedquery_ibfk_1;
406
407
408ALTER TABLE User MODIFY user_id INT UNSIGNED NOT NULL;
409ALTER TABLE ActionLimit MODIFY user_id INT UNSIGNED NOT NULL;
410ALTER TABLE DismissedCues MODIFY user_id INT UNSIGNED NOT NULL;
411ALTER TABLE User2Project MODIFY user_id INT UNSIGNED NOT NULL;
412ALTER TABLE ExtraPerm MODIFY user_id INT UNSIGNED NOT NULL;
413ALTER TABLE MemberNotes MODIFY user_id INT UNSIGNED NOT NULL;
414ALTER TABLE UserStar MODIFY starred_user_id INT UNSIGNED NOT NULL,
415 MODIFY user_id INT UNSIGNED NOT NULL;
416ALTER TABLE ProjectStar MODIFY user_id INT UNSIGNED NOT NULL;
417ALTER TABLE UserGroup MODIFY user_id INT UNSIGNED NOT NULL;
418ALTER TABLE UserGroup MODIFY group_id INT UNSIGNED NOT NULL;
419ALTER TABLE UserGroupSettings MODIFY group_id INT UNSIGNED NOT NULL;
420ALTER TABLE QuickEditHistory MODIFY user_id INT UNSIGNED NOT NULL;
421ALTER TABLE QuickEditMostRecent MODIFY user_id INT UNSIGNED NOT NULL;
422ALTER TABLE Issue MODIFY reporter_id INT UNSIGNED NOT NULL,
423 MODIFY owner_id INT UNSIGNED,
424 MODIFY derived_owner_id INT UNSIGNED;
425ALTER TABLE Issue2Cc MODIFY cc_id INT UNSIGNED NOT NULL;
426ALTER TABLE IssueStar MODIFY user_id INT UNSIGNED NOT NULL;
427ALTER TABLE Issue2FieldValue MODIFY user_id INT UNSIGNED;
428ALTER TABLE Comment MODIFY commenter_id INT UNSIGNED NOT NULL;
429ALTER TABLE Comment MODIFY deleted_by INT UNSIGNED;
430ALTER TABLE IssueUpdate MODIFY added_user_id INT UNSIGNED,
431 MODIFY removed_user_id INT UNSIGNED;
432ALTER TABLE Template MODIFY owner_id INT UNSIGNED;
433ALTER TABLE FieldDef2Admin MODIFY admin_id INT UNSIGNED NOT NULL;
434ALTER TABLE Template2Admin MODIFY admin_id INT UNSIGNED NOT NULL;
435ALTER TABLE Template2FieldValue MODIFY user_id INT UNSIGNED;
436ALTER TABLE Component2Admin MODIFY admin_id INT UNSIGNED NOT NULL;
437ALTER TABLE Component2Cc MODIFY cc_id INT UNSIGNED NOT NULL;
438ALTER TABLE User2SavedQuery MODIFY user_id INT UNSIGNED NOT NULL;
439
440ALTER TABLE User2Project ADD CONSTRAINT user2project_ibfk_2 FOREIGN KEY (user_id) REFERENCES User(user_id);
441ALTER TABLE ExtraPerm ADD CONSTRAINT extraperm_ibfk_2 FOREIGN KEY (user_id) REFERENCES User(user_id);
442ALTER TABLE MemberNotes ADD CONSTRAINT membernotes_ibfk_2 FOREIGN KEY (user_id) REFERENCES User(user_id);
443ALTER TABLE UserStar ADD CONSTRAINT userstar_ibfk_1 FOREIGN KEY (user_id) REFERENCES User(user_id);
444ALTER TABLE UserStar ADD CONSTRAINT userstar_ibfk_2 FOREIGN KEY (starred_user_id) REFERENCES User(user_id);
445ALTER TABLE ProjectStar ADD CONSTRAINT projectstar_ibfk_1 FOREIGN KEY (user_id) REFERENCES User(user_id);
446ALTER TABLE UserGroup ADD CONSTRAINT usergroup_ibfk_1 FOREIGN KEY (user_id) REFERENCES User(user_id);
447ALTER TABLE UserGroup ADD CONSTRAINT usergroup_ibfk_2 FOREIGN KEY (group_id) REFERENCES User(user_id);
448ALTER TABLE UserGroupSettings ADD CONSTRAINT usergroupsettings_ibfk_1 FOREIGN KEY (group_id) REFERENCES User(user_id);
449ALTER TABLE QuickEditHistory ADD CONSTRAINT quickedithistory_ibfk_2 FOREIGN KEY (user_id) REFERENCES User(user_id);
450ALTER TABLE QuickEditMostRecent ADD CONSTRAINT quickeditmostrecent_ibfk_2 FOREIGN KEY (user_id) REFERENCES User(user_id);
451ALTER TABLE Issue ADD CONSTRAINT issue_ibfk_2 FOREIGN KEY (reporter_id) REFERENCES User(user_id);
452ALTER TABLE Issue ADD CONSTRAINT issue_ibfk_3 FOREIGN KEY (owner_id) REFERENCES User(user_id);
453ALTER TABLE Issue ADD CONSTRAINT issue_ibfk_4 FOREIGN KEY (derived_owner_id) REFERENCES User(user_id);
454ALTER TABLE Issue2Cc ADD CONSTRAINT issue2cc_ibfk_2 FOREIGN KEY (cc_id) REFERENCES User(user_id);
455ALTER TABLE IssueStar ADD CONSTRAINT issuestar_ibfk_1 FOREIGN KEY (user_id) REFERENCES User(user_id);
456ALTER TABLE Issue2FieldValue ADD CONSTRAINT issue2fieldvalue_ibfk_2 FOREIGN KEY (user_id) REFERENCES User(user_id);
457ALTER TABLE Comment ADD CONSTRAINT comment_ibfk_3 FOREIGN KEY (commenter_id) REFERENCES User(user_id);
458ALTER TABLE Comment ADD CONSTRAINT comment_ibfk_4 FOREIGN KEY (deleted_by) REFERENCES User(user_id);
459ALTER TABLE FieldDef2Admin ADD CONSTRAINT fielddef2admin_ibfk_2 FOREIGN KEY (admin_id) REFERENCES User(user_id);
460ALTER TABLE Template2Admin ADD CONSTRAINT template2admin_ibfk_2 FOREIGN KEY (admin_id) REFERENCES User(user_id);
461ALTER TABLE Template2FieldValue ADD CONSTRAINT template2fieldvalue_ibfk_2 FOREIGN KEY (user_id) REFERENCES User(user_id);
462ALTER TABLE Component2Admin ADD CONSTRAINT component2admin_ibfk_2 FOREIGN KEY (admin_id) REFERENCES User(user_id);
463ALTER TABLE Component2Cc ADD CONSTRAINT component2cc_ibfk_2 FOREIGN KEY (cc_id) REFERENCES User(user_id);
464ALTER TABLE User2SavedQuery ADD CONSTRAINT user2savedquery_ibfk_1 FOREIGN KEY (user_id) REFERENCES User(user_id);
465
466================================================================
4672015-08-20: Add obscure_email column to User.
468
469ALTER TABLE User ADD obscure_email BOOLEAN DEFAULT TRUE;
470
471================================================================
4722015-09-14: Add role column to UserGroup.
473
474ALTER TABLE UserGroup ADD COLUMN role ENUM ('owner', 'member') NOT NULL DEFAULT 'member';
475
476================================================================
4772015-09-14: Remove via_id column from UserGroup.
478
479ALTER TABLE UserGroup DROP COLUMN via_id;
480
481================================================================
4822015-09-14: Add foreign key constraints to Issue2Foo tables
483
484ALTER TABLE Issue ADD CONSTRAINT issue_ibfk_5 FOREIGN KEY (status_id) REFERENCES StatusDef(id);
485ALTER TABLE Issue2Component ADD CONSTRAINT issue2component_ibfk_2 FOREIGN KEY (component_id) REFERENCES ComponentDef(id);
486ALTER TABLE Issue2Label ADD CONSTRAINT issue2label_ibfk_2 FOREIGN KEY (label_id) REFERENCES LabelDef(id);
487ALTER TABLE Issue2FieldValue ADD CONSTRAINT issue2fieldvalue_ibfk_3 FOREIGN KEY (field_id) REFERENCES FieldDef(id);
488
489================================================================
4902015-09-16: Use Binary collation on Varchar unique keys
491
492ALTER TABLE StatusDef MODIFY status VARCHAR(80) BINARY NOT NULL;
493ALTER TABLE ComponentDef MODIFY path VARCHAR(255) BINARY NOT NULL;
494ALTER TABLE LabelDef MODIFY label VARCHAR(80) BINARY NOT NULL;
495ALTER TABLE FieldDef MODIFY field_name VARCHAR(80) BINARY NOT NULL;
496ALTER TABLE Template MODIFY name VARCHAR(255) BINARY NOT NULL;
497
498================================================================
4992015-09-16: Have components use the same ID schema as Labels/Statuses
500
501ALTER TABLE ComponentDef MODIFY id INT NOT NULL AUTO_INCREMENT;
502ALTER TABLE Component2Admin MODIFY component_id INT NOT NULL;
503ALTER TABLE Component2Cc MODIFY component_id INT NOT NULL;
504ALTER TABLE Issue2Component MODIFY component_id INT NOT NULL;
505
506================================================================
5072015-09-17: Introduce DanglingIssueRelation table
508
509ALTER TABLE IssueRelation ADD CONSTRAINT issuerelation_ibfk_2 FOREIGN KEY (dst_issue_id) REFERENCES Issue(id);
510
511CREATE 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================================================================
5262015-09-18: Convert table char encodings to utf8.
527
528ALTER DATABASE monorail CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;
529ALTER TABLE Comment CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
530ALTER TABLE ComponentDef CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
531ALTER TABLE FieldDef CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
532ALTER TABLE IssueSummary CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
533ALTER TABLE LabelDef CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
534ALTER TABLE MemberNotes CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
535ALTER TABLE Project CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
536ALTER TABLE StatusDef CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
537
538================================================================
5392015-09-22: Make IssueRelation primary key more specific
540
541ALTER TABLE IssueRelation DROP PRIMARY KEY, ADD PRIMARY KEY (issue_id, dst_issue_id, kind);
542ALTER TABLE DanglingIssueRelation DROP PRIMARY KEY, ADD PRIMARY KEY (issue_id, dst_issue_project, dst_issue_local_id, kind);
543
544================================================================
5452015-09-29: Make cache_key unsigned so unsigned user ids can be invalidated.
546
547ALTER TABLE Invalidate MODIFY cache_key INT UNSIGNED NOT NULL;
548
549================================================================
5502015-09-29: Add external_group_type and external_group_name to UserGroupSettings
551
552ALTER TABLE UserGroupSettings ADD COLUMN external_group_type ENUM ('chrome_infra_auth', 'mdb');
553ALTER TABLE UserGroupSettings ADD COLUMN last_sync_time INT;
554
555================================================================
5562015-10-27: Eliminate Project.deliver_outbound_email because we have separate staging and prod instances.
557
558ALTER TABLE Project DROP COLUMN deliver_outbound_email;
559
560================================================================
5612015-10-27: Add SpamReport and is_spam fields to Issue and Comment
562
563ALTER TABLE Issue ADD COLUMN is_spam BOOL DEFAULT FALSE;
564ALTER TABLE Issue ADD INDEX (is_spam, project_id);
565
566ALTER TABLE Comment ADD COLUMN is_spam BOOL DEFAULT FALSE;
567ALTER 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.
572CREATE 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================================================================
5932015-11-03: Add new external group type chromium_committers
594
595ALTER TABLE UserGroupSettings MODIFY COLUMN external_group_type ENUM ('chrome_infra_auth', 'mdb', 'chromium_committers');
596
597================================================================
5982015-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.
603CREATE 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
636ALTER TABLE LocalIDCounter ADD used_spam_id int(11) NOT NULL;
637
638================================================================
6392015-11-13: Add Template2Component table.
640
641CREATE 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================================================================
6522015-11-13: Add new external group type baggins
653
654ALTER TABLE UserGroupSettings MODIFY COLUMN external_group_type ENUM ('chrome_infra_auth', 'mdb', 'chromium_committers', 'baggins');
655
656================================================================
6572015-11-18: Add new action kind api_request in ActionLimit
658
659ALTER TABLE ActionLimit MODIFY COLUMN action_kind ENUM ('project_creation', 'issue_comment', 'issue_attachment', 'issue_bulk_edit', 'api_request');
660
661================================================================
6622015-11-24: Add shard column to Issue, add indexes, and UPDATE existing rows.
663
664ALTER TABLE Issue ADD COLUMN shard SMALLINT UNSIGNED DEFAULT 0 NOT NULL;
665
666UPDATE Issue set shard = id % 10;
667
668ALTER TABLE Issue ADD INDEX (shard, status_id);
669ALTER TABLE Issue ADD INDEX (shard, project_id);
670
671================================================================
6722015-11-25: Remove external group type chromium_committers
673
674ALTER TABLE UserGroupSettings MODIFY COLUMN external_group_type ENUM ('chrome_infra_auth', 'mdb', 'baggins');
675
676================================================================
6772015-12-08: Modify handling of hidden well-known labels/statuses
678
679ALTER TABLE StatusDef ADD COLUMN hidden BOOLEAN DEFAULT FALSE;
680ALTER TABLE LabelDef ADD COLUMN hidden BOOLEAN DEFAULT FALSE;
681
682UPDATE StatusDef SET status=TRIM(LEADING '#' FROM status), hidden=TRUE WHERE status COLLATE UTF8_GENERAL_CI LIKE '#%';
683UPDATE LabelDef SET label=TRIM(LEADING '#' FROM label), hidden=TRUE WHERE label COLLATE UTF8_GENERAL_CI LIKE '#%';
684
685================================================================
6862015-12-11: Speed up moderation queue queries.
687
688ALTER TABLE SpamVerdict ADD INDEX(classifier_confidence);
689
690================================================================
6912015-12-14: Give components 'deprecated' col to match labels/statuses
692
693ALTER TABLE StatusDef CHANGE hidden deprecated BOOLEAN DEFAULT FALSE;
694ALTER TABLE LabelDef CHANGE hidden deprecated BOOLEAN DEFAULT FALSE;
695ALTER TABLE ComponentDef ADD COLUMN deprecated BOOLEAN DEFAULT FALSE;
696
697================================================================
6982015-12-14: Add table Group2Project
699
700CREATE 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================================================================
7112015-12-15: Increase maximum attachment quota bytes
712
713ALTER TABLE Project MODIFY attachment_bytes_used BIGINT DEFAULT 0;
714ALTER TABLE Project MODIFY attachment_quota BIGINT DEFAULT 0;
715
716================================================================
7172015-12-15: Simplify moderation queue queries.
718
719ALTER TABLE SpamVerdict ADD COLUMN overruled BOOL NOT NULL;
720ALTER TABLE SpamVerdict ADD COLUMN project_id INT NOT NULL;
721UPDATE SpamVerdict s JOIN Issue i ON i.id=s.issue_id SET s.project_id=i.project_id;
722
723================================================================
7242015-12-17: Add cols home_page and logo to table Project
725
726ALTER TABLE Project ADD COLUMN home_page VARCHAR(250);
727ALTER TABLE Project ADD COLUMN logo_gcs_id VARCHAR(250);
728ALTER TABLE Project ADD COLUMN logo_file_name VARCHAR(250);
729
730================================================================
7312015-12-28: Add component_required col to table Template;
732
733ALTER TABLE Template ADD component_required BOOLEAN DEFAULT FALSE;
734
735================================================================
7362016-01-05: Add issue_shard column to Issue2Label, Issue2Component,
737add indexes, and UPDATE existing rows.
738
739ALTER TABLE Issue2Component ADD COLUMN issue_shard SMALLINT UNSIGNED DEFAULT 0 NOT NULL;
740UPDATE Issue2Component set issue_shard = issue_id % 10;
741ALTER TABLE Issue2Component ADD INDEX (component_id, issue_shard);
742
743ALTER TABLE Issue2Label ADD COLUMN issue_shard SMALLINT UNSIGNED DEFAULT 0 NOT NULL;
744UPDATE Issue2Label set issue_shard = issue_id % 10;
745ALTER TABLE Issue2Label ADD INDEX (label_id, issue_shard);
746
747================================================================
7482016-01-06: Add period_soft_limit and period_hard_limit columns to ActionLimit
749
750ALTER TABLE ActionLimit ADD COLUMN period_soft_limit INT;
751ALTER TABLE ActionLimit ADD COLUMN period_hard_limit INT;
752
753================================================================
7542016-01-08: Add issue_shard column to Issue2FieldValue, Issue2Cc,
755add indexes, and UPDATE existing rows.
756
757ALTER TABLE Issue2FieldValue ADD COLUMN issue_shard SMALLINT UNSIGNED DEFAULT 0 NOT NULL;
758UPDATE Issue2FieldValue SET issue_shard = issue_id % 10;
759ALTER TABLE Issue2FieldValue ADD INDEX (field_id, issue_shard, int_value);
760ALTER TABLE Issue2FieldValue ADD INDEX (field_id, issue_shard, str_value(255));
761ALTER TABLE Issue2FieldValue ADD INDEX (field_id, issue_shard, user_id);
762
763ALTER TABLE Issue2Cc ADD COLUMN issue_shard SMALLINT UNSIGNED DEFAULT 0 NOT NULL;
764UPDATE Issue2Cc SET issue_shard = issue_id % 10;
765ALTER TABLE Issue2Cc ADD INDEX (cc_id, issue_shard);
766
767================================================================
7682015-12-17: Add documentation forwarding for /wiki urls
769
770ALTER TABLE Project ADD COLUMN docs_url VARCHAR(250);
771
772================================================================
7732015-12-17: Ensure SavedQueries never have null ids
774
775ALTER TABLE SavedQuery MODIFY id INT NOT NULL AUTO INCREMENT;
776
777================================================================
7782016-02-04: Add created, creator_id, modified, modifier_id for components
779
780ALTER TABLE ComponentDef ADD COLUMN created INT;
781ALTER TABLE ComponentDef ADD COLUMN creator_id INT UNSIGNED;
782ALTER TABLE ComponentDef ADD FOREIGN KEY (creator_id) REFERENCES User(user_id);
783ALTER TABLE ComponentDef ADD COLUMN modified INT;
784ALTER TABLE ComponentDef ADD COLUMN modifier_id INT UNSIGNED;
785ALTER TABLE ComponentDef ADD FOREIGN KEY (modifier_id) REFERENCES User(user_id);
786
787================================================================
7882016-02-19: Opt all privileged accounts into displaying full email.
789
790UPDATE User SET obscure_email = FALSE WHERE email LIKE "%@chromium.org";
791UPDATE User SET obscure_email = FALSE WHERE email LIKE "%@webrtc.org";
792UPDATE User SET obscure_email = FALSE WHERE email LIKE "%@google.com";
793
794================================================================
7952016-04-11: Increase email length limit to 255
796
797ALTER TABLE User MODIFY email VARCHAR(255);
798
799================================================================
8002016-04-14: Add forwarding for /source urls
801
802ALTER TABLE Project ADD COLUMN source_url VARCHAR(250);
803
804================================================================
8052016-04-27: Add prefs for compact email subject lines
806
807ALTER TABLE User ADD COLUMN email_compact_subject BOOLEAN DEFAULT FALSE;
808ALTER TABLE User ADD COLUMN email_view_widget BOOLEAN DEFAULT TRUE;
809
810================================================================
8112016-05-13: Add component labels
812
813CREATE 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================================================================
8242016-05-23: Add default search for members
825
826ALTER TABLE ProjectIssueConfig ADD COLUMN member_default_query TEXT;
827
828================================================================
8292016-06-17: Add is_description column to Comment
830
831Local:
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
834Staging/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================================================================
8382016-05-13: Add table AutocompleteExclusion
839
840CREATE 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===============================================================
8502016-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
853but be warned they will lock the db for some time if you have gigs of data in
854these tables */
855
856ALTER TABLE `monorail`.`Comment` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
857ALTER TABLE `monorail`.`IssueUpdate` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
858ALTER 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: */
868ALTER TABLE `monorail`.`Template` CHANGE `content` `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
869ALTER TABLE `monorail`.`Template` CHANGE `summary` `summary` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
870
871===============================================================
8722016-07-07: Add rank to IssueRelation
873
874ALTER TABLE IssueRelation ADD COLUMN rank BIGINT;
875
876==============================================================
8772016-07-13: Set default rank for blockedon relations
878
879UPDATE IssueRelation SET rank = 0 WHERE kind = 'blockedon';
880
881================================================================
8822016-08-01: Add timestamps for issue field changes
883
884DO NOT RUN THIS STATEMENT ON PROD OR STAGING. It is fine for localhost
885but be warned that it will lock the db for some time if you have gigs of data in
886these tables.
887ALTER TABLE Issue
888 ADD COLUMN owner_modified INT,
889 ADD COLUMN status_modified INT,
890 ADD COLUMN component_modified INT;
891
892Staging/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==============================================================
8992016-08-05: Add tables Hotlist, Hotlist2Issue, Hotlist2User
900
901CREATE 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
914CREATE 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
928CREATE 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==============================================================
9422016-08-10: Improve Hotlist schema
943
944ALTER TABLE Hotlist ADD COLUMN default_col_spec TEXT;
945
946ALTER TABLE Hotlist2User CHANGE role_name
947 role_name ENUM('owner', 'editor', 'follower');
948
949==============================================================
9502016-08-15: Add hotlist to Invalidate table
951
952ALTER TABLE Invalidate CHANGE kind
953 kind ENUM('user', 'project', 'issue', 'issue_id', 'hotlist');
954
955================================================================
9562016-09-21: Create the CommentContent table with emoji support.
957
958CREATE 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
969To copy comment strings from Comment to CommentContent, use
970the SQL procedure in monorail/tools/copy-comment-to-commentcontent.sql.
971
972If you need to roll back, you can reverse the process by reading
973and carefully using the SQL procedure in
974monorail/tools/copy-new-commentcontent-back-to-comment.sql.
975
976Optionally, after you have all comment content strings in
977CommentContent, you can reduce the size of the Comment table by using
978the procedure in monorail/tools/null-comment-table-strings.sql.
979This can make it faster to make more changes to the Comment table.
980
981================================================================
9822016-09-29: Drop was_escaped after Comment table is made smaller
983
984ALTER TABLE Comment DROP COLUMN was_escaped;
985
986================================================================
9872016-10-03: Add date-type custom fields
988
989ALTER TABLE Issue2FieldValue ADD date_value INT;
990ALTER TABLE Issue2FieldValue ADD INDEX (field_id, issue_shard, date_value);
991ALTER TABLE Template2FieldValue ADD date_value INT;
992ALTER TABLE FieldDef CHANGE field_type field_type ENUM (
993 'enum_type', 'int_type', 'str_type', 'user_type', 'date_type') NOT NULL;
994
995================================================================
9962016-10-13: Follow-up on splitting the Comment table
997
998ALTER TABLE Comment
999 DROP COLUMN content,
1000 DROP COLUMN inbound_message,
1001 ADD COLUMN commentcontent_id INT;
1002
1003ALTER TABLE Comment
1004 ADD FOREIGN KEY (commentcontent_id) REFERENCES CommentContent(id);
1005
1006After making those schema changes, run the commands in
1007tools/backfill-commentcontent-id.sql to fill in commentcontent_id
1008for existing comments.
1009
1010================================================================
10112016-10-13: Add new User fields
1012
1013ALTER 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================================================================
10192016-11-30: Drop unique key constraint on CommentContent.comment_id.
1020This is a prerequiste for deleting the code that sets a value for
1021that column. This resolves one TODO from 2016-09-21. Later the
1022column itself can be dropped, which is the other TODO from 2016-09-21.
1023
1024ALTER TABLE CommentContent DROP INDEX comment_id;
1025
1026================================================================
10272016-12-20: Add a table to keep track of hotlists that users have
1028starred.
1029
1030CREATE 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================================================================
10412017-12-04: Add two new columns to Hotlist2Issue.
1042
1043ALTER 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================================================================
10492017-01-30: Add one new column to SpamVerdict.
1050
1051ALTER TABLE SpamVerdict CHANGE reason
1052 reason ENUM ("manual", "threshold", "classifier", "fail_open") NOT NULL;
1053
1054================================================================
10552017-02-1: Add two tables to keep track of hotlists and bugs
1056that users have visited
1057
1058CREATE 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
1068CREATE 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================================================================
10802017-02-16: Add 'note' column to Hotlist2Issue table.
1081
1082ALTER TABLE Hotlist2Issue ADD COLUMN note TEXT;
1083
1084
1085================================================================
10862017-02-23: Add 'is_niche' column to FieldDef table.
1087
1088ALTER TABLE FieldDef ADD COLUMN is_niche BOOLEAN;
1089
1090
1091================================================================
10922017-03-05: Add 'ping_who' column to FieldDef table.
1093
1094ALTER TABLE FieldDef
1095 ADD COLUMN date_action ENUM ('no_action', 'ping_owner_only', 'ping_participants');
1096
1097
1098================================================================
10992017-05-02: Add index to make commentby: query term faster.
1100
1101ALTER TABLE Comment ADD INDEX (commenter_id, deleted_by, issue_id);
1102
1103
1104================================================================
11052017-05-12: Add user preference to ping issue starrers.
1106
1107ALTER TABLE User ADD COLUMN notify_starred_ping BOOLEAN DEFAULT FALSE;
1108
1109================================================================
11102017-06-15: Add table to map @google.com to @chromium.org accounts.
1111
1112CREATE 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================================================================
11212017-11-14: Add field_type ENUM url_type to FieldDef.
1122
1123ALTER TABLE FieldDef MODIFY field_type ENUM (
1124 'enum_type', 'int_type', 'str_type', 'user_type', 'date_type', 'url_type') NOT NULL;
1125
1126ALTER TABLE Issue2FieldValue ADD COLUMN url_value VARCHAR(1024);
1127ALTER TABLE Issue2FieldValue ADD INDEX (field_id, url_value);
1128
1129================================================================
11302017-11-22: Add url_value column to Template2FieldValue table.
1131
1132ALTER TABLE Template2FieldValue ADD COLUMN url_value VARCHAR(1024);
1133
1134================================================================
11352018-01-22: Add table to keep track of the latest timestamp that issues with
1136their component data were collected and uploaded to GCS.
1137
1138CREATE TABLE ComponentIssueClosedIndex (
1139 closed_index INT NOT NULL,
1140 PRIMARY KEY (closed_index)
1141) ENGINE=INNODB;
1142
1143================================================================
11442018-01-22: Add approval tables and approval_type to FieldDef.
1145
1146ALTER TABLE FieldDef MODIFY field_type ENUM (
1147 'enum_type', 'int_type', 'str_type', 'user_type', 'date_type', 'url_type', 'approval_type') NOT NULL;
1148
1149CREATE 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
1160CREATE 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
1179CREATE 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================================================================
11942018-01-29: Add is_deleted column to ComponentDef table and remove
1195uniqueness constraint for component names in a project.
1196
1197ALTER TABLE ComponentDef ADD COLUMN is_deleted BOOLEAN DEFAULT FALSE;
1198ALTER TABLE ComponentDef ADD INDEX project_id2 (project_id, path);
1199ALTER TABLE ComponentDef DROP INDEX project_id;
1200
1201================================================================
12022018-01-30: Add IssueSnapshot table and join tables
1203
1204CREATE 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
1226CREATE 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
1235CREATE 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
1244CREATE 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===============================================================
12542018-01-29: Add approval_id column to FieldDef table
1255
1256ALTER TABLE FieldDef ADD COLUMN approval_id INT;
1257
1258===============================================================
12592018-02-08: Drop previous approval tables and add default approvers table
1260
1261DROP TABLE ApprovalStatusDef;
1262DROP TABLE Approval2Approver;
1263DROP TABLE Issue2ApprovalValue;
1264
1265CREATE 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==================================================================
12762018-02-09: Add project_id column to default approvers table
1277
1278ALTER TABLE ApprovalDef2Approver ADD project_id SMALLINT UNSIGNED NOT NULL;
1279ALTER TABLE ApprovalDef2Approver ADD CONSTRAINT ApprovalDef2Approver_ibfk_3 FOREIGN KEY (project_id) REFERENCES Project(project_id);
1280
1281==================================================================
12822018-02-14: Expand IssueSnapshot time columns from INT to INT UNSIGNED
1283ALTER TABLE IssueSnapshot MODIFY period_start INT UNSIGNED NOT NULL;
1284ALTER TABLE IssueSnapshot MODIFY period_end INT UNSIGNED NOT NULL;
1285
1286
1287================================================================
12882018-02-22: Relax some constraints on issue snapshots
1289
1290ALTER TABLE IssueSnapshot MODIFY status_id int;
1291ALTER TABLE IssueSnapshot DROP INDEX issue_id;
1292ALTER TABLE IssueSnapshot ADD INDEX (`issue_id`,`period_start`,`period_end`);
1293
1294================================================================
12952018-03-12: Add launch template milestones and approval tables
1296
1297CREATE 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
1307CREATE 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================================================================
13222018-03-13: Edit approval state enum
1323
1324ALTER TABLE Template2ApprovalValue CHANGE launch_status status ENUM (
1325 'needs_review', 'na', 'review_requested', 'started', 'need_info', 'approved', 'not_approved');
1326
1327
1328================================================================
13292018-03-14: Edit approval state enum *AGAIN*
1330
1331ALTER TABLE Template2ApprovalValue MODIFY status ENUM (
1332 'needs_review', 'na', 'review_requested', 'started', 'need_info', 'approved', 'not_approved', 'not_set');
1333
1334
1335================================================================
13362018-03-15: Add Issue Approval and Mileston tables
1337
1338DROP TABLE IF EXISTS Approval2Approver;
1339DROP TABLE IF EXISTS Issue2ApprovalValue;
1340
1341CREATE 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
1351CREATE 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
1366CREATE 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
1377ALTER 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================================================================
13812018-03-15: Soft-delete Hotlists.
1382ALTER TABLE Hotlist ADD COLUMN is_deleted BOOLEAN DEFAULT FALSE;
1383
1384===============================================================
13852018-03-19: Rename issue approvers table.
1386
1387RENAME TABLE IssueApproval2Approvers TO IssueApproval2Approver;
1388
1389================================================================
13902018-03-22: Add Hotlist support to IssueSnapshots.
1391
1392CREATE 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================================================================
14022018-03-23: Add ApprovalDef2Survey table.
1403
1404CREATE 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===============================================================
14162018-03-24: Add IssueApproval2Comment table.
1417
1418CREATE 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===============================================================
14292018-03-29: Rename Milestones to Phases.
1430
1431CREATE 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
1441CREATE 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
1451ALTER TABLE Issue2ApprovalValue DROP FOREIGN KEY Issue2ApprovalValue_ibfk_4;
1452ALTER TABLE Issue2ApprovalValue ADD COLUMN phase_id int NOT NULL;
1453CREATE INDEX IF NOT EXISTS phase_id ON Issue2ApprovalValue (phase_id);
1454ALTER TABLE Issue2ApprovalValue ADD FOREIGN KEY (phase_id) REFERENCES Issue2Phase(id);
1455
1456ALTER TABLE Template2ApprovalValue DROP FOREIGN KEY Template2ApprovalValue_ibfk_3;
1457ALTER TABLE Template2ApprovalValue ADD COLUMN phase_id int NOT NULL;
1458CREATE INDEX IF NOT EXISTS phase_id ON Template2ApprovalValue (phase_id);
1459ALTER TABLE Template2ApprovalValue ADD FOREIGN KEY (phase_id) REFERENCES Template2Phase(id);
1460
1461================================================================
14622018-04-18: Drop all milestone schema.
1463
1464ALTER TABLE Template2ApprovalValue DROP COLUMN milestone_id;
1465ALTER TABLE Issue2ApprovalValue DROP COLUMN milestone_id;
1466
1467DROP TABLE Template2Milestone;
1468DROP TABLE Issue2Milestone;
1469
1470================================================================
14712018-04-25: Add phase_id to X2ApprovalValue tables' primary keys.
1472
1473ALTER TABLE Template2ApprovalValue DROP PRIMARY KEY, ADD PRIMARY KEY(approval_id, template_id, phase_id);
1474ALTER TABLE Issue2ApprovalValue DROP PRIMARY KEY, ADD PRIMARY KEY(issue_id, approval_id, phase_id);
1475
1476==================================================================
14772018-04-30: Rename Issue2Phase table to IssuePhaseDef: Part One
1478
1479CREATE 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
1487ALTER TABLE Issue2ApprovalValue DROP FOREIGN KEY Issue2ApprovalValue_ibfk_4;
1488ALTER TABLE Issue2ApprovalValue ADD FOREIGN KEY (phase_id) REFERENCES IssuePhaseDef(id);
1489
1490==================================================================
14912018-05-02: Add phase_id to Issue2FieldValue table.
1492
1493ALTER TABLE Issue2FieldValue ADD COLUMN phase_id INT;
1494ALTER TABLE Issue2FieldValue ADD FOREIGN KEY (phase_id) REFERENCES IssuePhaseDef(id);
1495
1496===================================================================
14972018-5-01: Add is_phase_field to FieldDef.
1498
1499ALTER TABLE FieldDef ADD COLUMN is_phase_field BOOLEAN DEFAULT FALSE;
1500
1501===================================================================
15022018-5-11: Rename Issue2Phase table to IssuePhaseDef: Part Two, drop Issue2Phase
1503
1504DROP TABLE Issue2Phase;
1505==================================================================
15062018-05-11: Restrict size of index field in Issue2FieldValue
1507
1508ALTER TABLE Issue2FieldValue DROP INDEX field_id_5;
1509ALTER TABLE Issue2FieldValue ADD INDEX (field_id, issue_shard, url_value(255));
1510
1511==================================================================
15122018-05-18: Replace Template2Phase FK with IssuePhaseDef.
1513
1514TRUNCATE TABLE Template2ApprovalValue;
1515ALTER TABLE Template2ApprovalValue DROP FOREIGN KEY Template2ApprovalValue_ibfk_3;
1516ALTER TABLE Template2ApprovalValue ADD FOREIGN KEY (phase_id) REFERENCES IssuePhaseDef(id);
1517
1518================================================================
15192018-05-22: Add boolean columns to control autocomplete exclusions.
1520
1521ALTER TABLE AutocompleteExclusion
1522 ADD COLUMN ac_exclude BOOLEAN DEFAULT TRUE,
1523 ADD COLUMN no_expand BOOLEAN DEFAULT FALSE;
1524
1525==================================================================
15262018-05-30: Add comment to Invalidate table
1527
1528ALTER TABLE Invalidate CHANGE kind
1529 kind ENUM('user', 'project', 'issue', 'issue_id', 'hotlist',
1530 'comment');
1531
1532=================================================================
15332018-06-05: Drop Template2Phase tbl and NOT NULL constraint for approval value phase_id columns.
1534
1535DROP TABLE Template2Phase;
1536
1537ALTER TABLE Issue2ApprovalValue DROP PRIMARY KEY, ADD PRIMARY KEY(issue_id, approval_id);
1538ALTER TABLE Issue2ApprovalValue MODIFY COLUMN phase_id INT;
1539
1540ALTER TABLE Template2ApprovalValue DROP PRIMARY KEY, ADD PRIMARY KEY(approval_id, template_id);
1541ALTER TABLE Template2ApprovalValue MODIFY COLUMN phase_id INT;
1542
1543=================================================================
15442018-06-22: Add 'template' to Invalidate.kind_enum
1545
1546ALTER TABLE Invalidate MODIFY COLUMN kind enum('user', 'project', 'issue', 'issue_id', 'hotlist', 'comment', 'template') NOT NULL;
1547
1548=================================================================
15492018-07-02: Add UserCommits table to keep track of commits.
1550
1551CREATE 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=================================================================
15662018-07-16: Drop parent_sha because it isn't needed in this table and give commit_repo a clearer name.
1567
1568ALTER TABLE UserCommits DROP COLUMN parent_sha;
1569ALTER TABLE UserCommits CHANGE commit_repo commit_repo_url VARCHAR(255);
1570
1571
1572================================================================
15732018-08-27: Allow computed external user groups, e.g., everyone@google.com.
1574
1575ALTER TABLE UserGroupSettings
1576 MODIFY COLUMN
1577 external_group_type ENUM ('chrome_infra_auth', 'mdb', 'baggins', 'computed');
1578
1579
1580================================================================
15812018-09-24: Add 'usergroup to Invalidate.kind enum
1582
1583ALTER TABLE Invalidate MODIFY COLUMN kind enum(
1584 'user', 'usergroup', 'project', 'issue', 'issue_id',
1585 'hotlist', 'comment', 'template') NOT NULL;
1586
1587================================================================
15882018-10-30: Fix ApprovalValue status enum for 'review_started'
1589
1590ALTER 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
1593ALTER 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================================================================
15982018-11-02: Redo LinkedAccount table.
1599
1600DROP TABLE LinkedAccount;
1601CREATE 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================================================================
16122018-12-03: Create LinkedAccountInvite table.
1613
1614CREATE 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==================================================================================
16252018-1-15: Add notify_group and notify_members bool col to UserGroupSettings table.
1626
1627ALTER TABLE UserGroupSettings ADD COLUMN notify_members BOOLEAN DEFAULT TRUE;
1628ALTER TABLE UserGroupSettings ADD COLUMN notify_group BOOLEAN DEFAULT FALSE;
1629
1630=================================================================
16312019-01-23: Add two new indexes to IssueSnapshot for performance.
1632
1633CREATE INDEX by_period_start ON IssueSnapshot (shard, project_id, status_id, period_start);
1634CREATE INDEX by_period_end ON IssueSnapshot (shard, project_id, status_id, period_end);
1635
1636
1637================================================================
16382019-01-25: Start a more flexible way of storing user preferences.
1639
1640CREATE 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================================================================
16492019-04-10: Set UserPrefs that indicate that privacy click-through was seen.
1650This is part of phasing out DismissedCues.
1651
1652INSERT IGNORE INTO UserPrefs (user_id, name, value)
1653SELECT user_id, cue, 'true'
1654FROM DismissedCues;
1655
1656================================================================
16572019-05-13: Drop unused ActionLimit table.
1658
1659DROP TABLE ActionLimit;
1660
1661================================================================
16622019-05-24: Add ext_issue_identifier column to DanglingIssueRelation table.
1663
1664ALTER TABLE DanglingIssueRelation ADD COLUMN ext_issue_identifier VARCHAR(2048);
1665ALTER TABLE DanglingIssueRelation ADD INDEX (ext_issue_identifier);
1666
1667================================================================
16682019-06-06: Allow full unicode labels.
1669
1670ALTER TABLE LabelDef CHANGE label label VARCHAR(80) BINARY NOT NULL COLLATE utf8mb4_unicode_ci;
1671
1672================================================================
16732019-06-07: Add indexes to reduce cases of using filesort
1674
1675ALTER TABLE HotlistVisitHistory ADD INDEX (user_id, viewed);
1676ALTER TABLE ReindexQueue ADD INDEX (created);
1677
1678================================================================
16792019-06-13: Add ext_issue_identifier to DanglingIssueRelation PRIMARY KEY.
1680
1681ALTER TABLE DanglingIssueRelation MODIFY COLUMN ext_issue_identifier VARCHAR(255);
1682ALTER TABLE DanglingIssueRelation DROP PRIMARY KEY, ADD PRIMARY KEY(issue_id, dst_issue_project, dst_issue_local_id, kind, ext_issue_identifier);
1683
1684================================================================
16852019-06-25: Add unique constraint on SpamReport.
1686
1687ALTER IGNORE TABLE SpamReport ADD UNIQUE (user_id, comment_id, issue_id);
1688
1689================================================================
16902019-07-03: Add CommentImporter table.
1691
1692CREATE 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================================================================
17032019-10-09: Drop DismissedCues because that data has been in UserPrefs since April.
1704
1705DROP TABLE DismissedCues;
1706
1707================================================================
17082019-10-24: Insert row representing deleted user.
1709
1710INSERT IGNORE INTO User (user_id, email) VALUES (1, '');
1711
1712==================================================================
17132019-11-21: Add hotlist_id to Invalidate table.
1714
1715ALTER TABLE Invalidate CHANGE kind
1716 kind ENUM('user', 'usergroup', 'project', 'issue', 'issue_id', 'hotlist', 'comment', 'template', 'hotlist_id');
1717
1718
1719================================================================
17202019-12-30: Set custom revision_url_format for pigweed project.
1721
1722UPDATE Project SET revision_url_format = 'https://pigweed-review.git.corp.google.com/q/{revnum}' WHERE project_name='pigweed';
1723
1724================================================================
17252020-02-19: Create table for editors of a field. Also, add column in FieldDef
1726to indicate if the editors of that field are being restricted.
1727
1728CREATE 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
1738ALTER TABLE FieldDef ADD COLUMN is_restricted_field BOOL DEFAULT FALSE;
1739
1740================================================================
17412020-05-14: Add option to force detailed notifications for projects.
1742
1743ALTER TABLE Project ADD COLUMN issue_notify_always_detailed BOOLEAN DEFAULT FALSE;
1744