Page MenuHomePhabricator

Implement high-level database schema to store addresses
Closed, ResolvedPublic5 Estimated Story Points

Description

This ticket captures the work required to implement findings of T316127

Acceptance criteria:

Create the new tables below to store addresses, and change the code as needed to save and read from the new columns.
https://dbdesigner.page.link/r5x5E6zP14iXMGN6A

Screen Shot 2022-08-31 at 00.56.43.png (840×1 px, 207 KB)

ALTERs to run on beta

Before merging the patch:

CREATE TABLE ce_address (
  cea_id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL,
  cea_full_address BLOB NOT NULL,
  cea_country VARBINARY(255) DEFAULT NULL,
  PRIMARY KEY(cea_id)
);

CREATE TABLE ce_event_address (
  ceea_id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL,
  ceea_event BIGINT UNSIGNED NOT NULL,
  ceea_address BIGINT UNSIGNED NOT NULL,
  UNIQUE INDEX ceea_event_address (ceea_event, ceea_address),
  PRIMARY KEY(ceea_id)
);

ALTER TABLE campaign_events ALTER COLUMN event_meeting_country SET DEFAULT 'xxx-new-row';
ALTER TABLE campaign_events ALTER COLUMN event_meeting_address SET DEFAULT 'xxx-new-row';

After merging the patch:

INSERT INTO ce_address (cea_country, cea_full_address) SELECT event_meeting_country, CONCAT(event_meeting_address, " \n ", event_meeting_country) FROM campaign_events WHERE ( event_meeting_country != '' OR event_meeting_address != '' ) and event_meeting_country != 'xxx-new-row' and event_meeting_address != 'xxx-new-row';
INSERT INTO ce_event_address (ceea_event, ceea_address) SELECT event_id, cea_id FROM campaign_events JOIN ce_address ON CONCAT(event_meeting_address, " \n ", event_meeting_country) = cea_full_address;

ALTER TABLE campaign_events DROP COLUMN event_meeting_country;
ALTER TABLE campaign_events DROP COLUMN event_meeting_address;
NOTE: Since we're not doing this in a backwards-compatible way, you will have to alter the tables manually on your local once the patch is merged

Event Timeline

ldelench_wmf set the point value for this task to 2.
ldelench_wmf changed the point value for this task from 2 to 5.Aug 25 2022, 5:20 PM
vyuen changed the task status from Open to In Progress.Aug 30 2022, 12:13 PM

Change 828656 had a related patch set uploaded (by Cmelo; author: Cmelo):

[mediawiki/extensions/CampaignEvents@master] Add new address tables

https://gerrit.wikimedia.org/r/828656

Moving this to code review, here is a diagram of how it was implemented.

Test wiki created on Patch demo by Daimona Eaytoy using patch(es) linked to this task:
https://patchdemo.wmflabs.org/wikis/50504d3e6d/w

Mentioned in SAL (#wikimedia-releng) [2022-09-19T11:57:53Z] <Daimona> Applying schema change to the wikishared DB on beta for the CampaignEvents extension (1/2) # T316128

Change 828656 merged by jenkins-bot:

[mediawiki/extensions/CampaignEvents@master] Add ce_address and ce_event_address table.

https://gerrit.wikimedia.org/r/828656

Mentioned in SAL (#wikimedia-releng) [2022-09-19T12:06:40Z] <Daimona> Applying schema change to the wikishared DB on beta for the CampaignEvents extension (2/2) # T316128

vaughnwalters subscribed.

DESCRIBE ce_address; on betacluster

Screen Shot 2022-09-19 at 11.41.25 PM.png (312×1 px, 60 KB)

DESCRIBE ce_event_address; on betacluster:

Screen Shot 2022-09-19 at 11.43.18 PM.png (288×1 px, 61 KB)

DESCRIBE campaign_events; showing that event_meeting_country and event_meeting_address have been successfully dropped

Screen Shot 2022-09-19 at 11.48.03 PM.png (854×1 px, 229 KB)

There is data in the ce_address table (screenshot is just a sample):

Screen Shot 2022-09-20 at 9.54.32 AM.png (1×1 px, 194 KB)

and there is also data in ce_event_address

Screen Shot 2022-09-20 at 9.55.08 AM.png (898×904 px, 86 KB)

This ticket looks good and I am marking it as done ✅

Test wiki on Patch demo by Daimona Eaytoy using patch(es) linked to this task was deleted:

https://patchdemo.wmflabs.org/wikis/50504d3e6d/w/