You are here

blogapi.install in Drupal 5

Same filename and directory in other branches
  1. 6 modules/blogapi/blogapi.install

File

modules/blogapi/blogapi.install
View source
<?php

/**
 * Implementation of hook_install().
 */
function blogapi_install() {

  // Create table.
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {blogapi_files} (\n        fid int NOT NULL auto_increment,\n        uid int unsigned NOT NULL default 0,\n        filepath varchar(255) NOT NULL default '',\n        filesize int unsigned NOT NULL default 0,\n        PRIMARY KEY (fid),\n        KEY uid (uid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {blogapi_files} (\n        fid serial,\n        uid int_unsigned NOT NULL default 0,\n        filepath varchar(255) NOT NULL default '',\n        filesize int_unsigned NOT NULL default 0,\n        PRIMARY KEY (fid)\n      )");
      db_query("CREATE INDEX {blogapi_files}_uid_idx ON {blogapi_files} (uid)");
      break;
  }
}

/**
 * Implementation of hook_uninstall().
 */
function blogapi_uninstall() {

  // Remove table.
  db_query("DROP TABLE {blogapi_files}");
}

/**
 * @defgroup updates-5.x-extra Extra blogapi updates for 5.x
 * @{
 */

/**
 * Add blogapi_files table to enable size restriction for BlogAPI file uploads.
 *
 * Added in Drupal 5.10 (and 6.4).
 */
function blogapi_update_5000() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("CREATE TABLE {blogapi_files} (\n        fid int NOT NULL auto_increment,\n        uid int unsigned NOT NULL default 0,\n        filepath varchar(255) NOT NULL default '',\n        filesize int unsigned NOT NULL default 0,\n        PRIMARY KEY (fid),\n        KEY uid (uid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      break;
    case 'pgsql':
      $ret[] = update_sql("CREATE TABLE {blogapi_files} (\n        fid serial,\n        uid int_unsigned NOT NULL default 0,\n        filepath varchar(255) NOT NULL default '',\n        filesize int_unsigned NOT NULL default 0,\n        PRIMARY KEY (fid)\n      )");
      $ret[] = update_sql("CREATE INDEX {blogapi_files}_uid_idx ON {blogapi_files} (uid)");
      break;
  }
  return $ret;
}

/**
 * @} End of "defgroup updates-5.x-extra"
 */

Functions

Namesort descending Description
blogapi_install Implementation of hook_install().
blogapi_uninstall Implementation of hook_uninstall().
blogapi_update_5000 Add blogapi_files table to enable size restriction for BlogAPI file uploads.