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