You are here

function simplenews_update_6252 in Simplenews 6.2

Add 'sent_subscriber_count' field to 'simplenews_newsletters' table.

File

./simplenews.install, line 847
Simplenews installation.

Code

function simplenews_update_6252() {
  $ret = array();
  db_add_field($ret, 'simplenews_newsletters', 'sent_subscriber_count', array(
    'description' => 'The count of subscribers to the newsletter when it was sent.',
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
  ));
  db_query("\n    UPDATE {simplenews_newsletters} sn\n    SET sent_subscriber_count = (\n      SELECT count(tid)\n      FROM {simplenews_snid_tid} AS sst\n      INNER JOIN {simplenews_subscriptions} AS ss\n        ON sst.snid = ss.snid\n      WHERE tid = sn.tid\n        AND ss.activated = %d\n    )", SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED);
  return $ret;
}