Page MenuHomePhabricator

Convert banner history from a drupal table to a column in contribution_tracking
Closed, ResolvedPublic

Description

@Dwisehaupt in order to roll this out during the maintenance window it's probably best if you run these 2 sql queries at a time that works for you. Once you have run them we can deploy the cover to switch our usage over & re-run the second query to mop up any transitional ones. I'm running the second query on staging now to try to get timings - but batching it is an option

The first query actually ran quickly on staging...

ALTER TABLE civicrm_contribution_tracking ADD COLUMN
      `banner_history_log_id` varchar(255) COMMENT 'Temporary banner history log ID to associate banner history EventLogging events.'

The second probably not so quick (oops didn't check back for an hour but was done then)

UPDATE civicrm_contribution_tracking t
      LEFT JOIN drupal.banner_history_contribution_associations b
        ON b.contribution_tracking_id = t.id
      SET t.banner_history_log_id = b.banner_history_log_id
      WHERE t.banner_history_log_id IS NULL

Event Timeline

@Pcoombe @JMando I realise we didn't catch you up with this - our plan is to remove the banner_history_association table during the maintenance window next week - ie

  1. add the field banner_history_log_id to civicrm_contribution_tracking
  2. populate that field instead of banner_history_contribution_associations
  3. DROP the table banner_history_contribution_associations from the drupal DB (this could be delayed if need be but it would not be getting new data)

Thanks for letting us know @Eileenmcnaughton, sounds like a nice simplification. I don't have any queries relating to banner history myself

Tried the first query but looks like the civicrm_contribution_tracking table doesn't have that banner_history_log_id column.

MariaDB [civicrm]> UPDATE civicrm_contribution_tracking t
    -> LEFT JOIN drupal.banner_history_contribution_associations b
    ->   ON b.contribution_tracking_id = t.id
    -> SET t.banner_history_log_id = b.banner_history_log_id
    -> WHERE t.banner_history_log_id IS NULL;
ERROR 1054 (42S22): Unknown column 't.banner_history_log_id' in 'field list'

Maybe a discrepancy between staging and prod? Let me know how you want to continue.

@Dwisehaupt are the first query was to add it - but looking above it seems I posted the second query twice

it should have been

ALTER TABLE civicrm_contribution_tracking ADD COLUMN
      `banner_history_log_id` varchar(255) COMMENT 'Temporary banner history log ID to associate banner history EventLogging events.'

https://gerrit.wikimedia.org/r/c/wikimedia/fundraising/crm/+/1032117/2/drupal/sites/default/civicrm/extensions/wmf-civicrm/CRM/Wmf/Upgrader.php

Ok, both queries have been run. Here's the output from the important second one:

MariaDB [civicrm]> UPDATE civicrm_contribution_tracking t
    -> LEFT JOIN drupal.banner_history_contribution_associations b
    ->   ON b.contribution_tracking_id = t.id
    -> SET t.banner_history_log_id = b.banner_history_log_id
    -> WHERE t.banner_history_log_id IS NULL;
Query OK, 60257643 rows affected (36 min 48.125 sec)
Rows matched: 205244491  Changed: 60257643  Warnings: 0

Updated the description to have the correct first query.

Putting this in pending deployment as there is one last patch to deploy https://gerrit.wikimedia.org/r/c/wikimedia/fundraising/crm/+/1032895 - it's not +2 yet only because there might be some need to do last checks before deployment but it is +2 really.....

XenoRyet moved this task from Pending Deployment to Done on the Fundraising Sprint: justWork() board.
XenoRyet set Final Story Points to 2.