You are here

asset.install in Asset 5.2

Same filename and directory in other branches
  1. 5 asset.install
  2. 6 asset.install
  3. 7 asset.install

Asset module install file

File

asset.install
View source
<?php

/**
* @file
* Asset module install file
*/

/**
 * Implementation of hook_install()
 */
function asset_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {asset} (\n        aid int unsigned NOT NULL,\n        type varchar(32) NOT NULL default '',\n        title varchar(128) NOT NULL default '',\n        uid int NOT NULL default '0',\n        status int NOT NULL default '1',\n        created int NOT NULL default '0',\n        changed int NOT NULL default '0',\n        pid int unsigned NOT NULL,\n        credit varchar(255) NOT NULL,\n        description text NOT NULL,\n        PRIMARY KEY  (aid)\n      ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
      db_query("CREATE TABLE {asset_node} (\n        aid int(10) unsigned NOT NULL,\n        nid int(10) unsigned NOT NULL,\n        refs int(10) unsigned NOT NULL default '0',\n        PRIMARY KEY  (aid,nid)\n      ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
      db_query("CREATE TABLE {asset_files} (\n        aid int unsigned NOT NULL default 0,\n        fid int unsigned NOT NULL default 0,\n        label varchar(32) NOT NULL,\n        PRIMARY KEY  (aid)\n      ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
      db_query("CREATE TABLE {asset_role} (\n        aid int(10) unsigned NOT NULL,\n        rid int(10) unsigned NOT NULL,\n        status tinyint unsigned NOT NULL default '0',\n        PRIMARY KEY  (aid,rid)\n      ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':

      //TODO: postgresql
      break;
  }
  drupal_set_message(t('Asset tables have been configured.'));
}
function asset_update_1() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("ALTER TABLE {asset_files} ADD COLUMN label varchar(32) NOT NULL default ''");
      $ret[] = update_sql('UPDATE {asset_files} SET label="default"');
  }
  return $ret;
}
function asset_update_2() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("ALTER TABLE {asset} ADD COLUMN credit varchar(255) NOT NULL default ''");
      $ret[] = update_sql("ALTER TABLE {asset} ADD COLUMN description text NOT NULL default ''");
  }
  return $ret;
}
function asset_update_3() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("CREATE TABLE {asset_role} (\n        aid int(10) unsigned NOT NULL,\n        rid int(10) unsigned NOT NULL,\n        status tinyint unsigned NOT NULL default '0',\n        PRIMARY KEY  (aid,rid)\n      ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
  }
  return $ret;
}
function asset_uninstall() {
  db_query('DROP TABLE {asset}');
  db_query('DROP TABLE {asset_node}');
  db_query('DROP TABLE {asset_files}');
}