You are here

ad_notify.install in Advertisement 5.2

Same filename and directory in other branches
  1. 5 notify/ad_notify.install
  2. 6 notify/ad_notify.install

File

notify/ad_notify.install
View source
<?php

/**
 * Ad_notify module database schema.
 * Copyright (c) 2007 Jeremy Andrews <jeremy@kerneltrap.org>
 * All rights reserved.
 */
function ad_notify_install() {
  switch ($GLOBALS['db_type']) {
    case 'pgsql':

      /**
       * Notifications can be granted to each owner of each ad.  The same owner
       * can own multiple ads, and can have different notifications for each
       * ad.  Notifications are defined by their type and an offset in seconds.
       * For example, 'day, 0' would send a notification at the start of
       * every day, and 'expire, -86400' would send a notification one day
       * before the ad expires.
       */
      db_query("CREATE TABLE {ad_notify} (\n      notid SERIAL NOT NULL PRIMARY KEY,\n      aid INT NOT NULL DEFAULT '0',\n      oid INT NOT NULL DEFAULT '0',\n\n      event VARCHAR(255) NOT NULL DEFAULT '',\n      delay INT NOT NULL DEFAULT '0',\n      queued INT NOT NULL DEFAULT '0',\n      time INT NOT NULL DEFAULT '0',\n      sent INT NOT NULL DEFAULT '0',\n      counter INT NOT NULL DEFAULT '0',\n      locked INT NOT NULL DEFAULT '0',\n      expire INT NOT NULL DEFAULT '0',\n      status INT NOT NULL DEFAULT '0',\n\n      address VARCHAR(255) NOT NULL DEFAULT '',\n      subject VARCHAR(255) NOT NULL DEFAULT '',\n      body TEXT NOT NULL DEFAULT '',\n\n      UNIQUE (oid, event, delay)\n      );");
      break;
    case 'mysql':
    case 'mysqli':
    default:

      /**
       * Notifications can be granted to each owner of each ad.  The same owner
       * can own multiple ads, and can have different notifications for each
       * ad.  Notifications are defined by their type and an offset in seconds.
       * For example, 'day, 0' would send a notification at the start of
       * every day, and 'expire, -86400' would send a notification one day
       * before the ad expires.
       */
      db_query("CREATE TABLE {ad_notify} (\n      notid INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n      aid INT(11) UNSIGNED NOT NULL DEFAULT '0',\n      oid INT(11) UNSIGNED NOT NULL DEFAULT '0',\n\n      event VARCHAR(255) NOT NULL DEFAULT '',\n      delay INT(11) SIGNED NOT NULL DEFAULT '0',\n      queued INT(11) SIGNED NOT NULL DEFAULT '0',\n      sent INT(11) SIGNED NOT NULL DEFAULT '0',\n      counter INT(7) UNSIGNED NOT NULL DEFAULT '0',\n      locked TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',\n      expire TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',\n      status TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',\n\n      address VARCHAR(255) NOT NULL DEFAULT '',\n      subject VARCHAR(255) NOT NULL DEFAULT '',\n      body TEXT NULL,\n\n      PRIMARY KEY  (notid),\n      UNIQUE KEY  (oid, event, delay),\n      KEY  (oid),\n      KEY  (event),\n      KEY  (delay),\n      KEY  (queued),\n      KEY  (sent),\n      KEY  (status)\n    ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
  }
  drupal_set_message(t('The ad_notify table has been created.'));
}

/**
 * Allow complete uninstallation of the ad_notify module.
 */
function ad_notify_uninstall() {

  // Drop all ad_notify module tables.
  db_query('DROP TABLE {ad_notify}');
}
function ad_notify_update_1() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    default:
      $ret[] = update_sql("ALTER TABLE {ad_notify} ADD aid INT(11) UNSIGNED NOT NULL DEFAULT '0'");
  }
  return $ret;
}

/**
 * Convert to utf8 character set for all tables to allow for proper 
 * internationalization.
 */
function ad_notify_update_2() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'pgsql':
      break;
    default:
      $ret[] = update_sql("ALTER TABLE {ad_notify} CONVERT TO CHARACTER SET utf8");
  }
  return $ret;
}

Functions

Namesort descending Description
ad_notify_install Ad_notify module database schema. Copyright (c) 2007 Jeremy Andrews <jeremy@kerneltrap.org> All rights reserved.
ad_notify_uninstall Allow complete uninstallation of the ad_notify module.
ad_notify_update_1
ad_notify_update_2 Convert to utf8 character set for all tables to allow for proper internationalization.