You are here

function asset_install in Asset 5

Same name and namespace in other branches
  1. 5.2 asset.install \asset_install()
  2. 6 asset.install \asset_install()
  3. 7 asset.install \asset_install()

Implementation of hook_install()

File

./asset.install, line 6

Code

function asset_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {asset} (\n        aid int(10) unsigned NOT NULL,\n        type varchar(32) NOT NULL default '',\n        dirname varchar(128) NOT NULL default '',\n        extension varchar(128) NOT NULL default '',\n        filename varchar(255) NOT NULL default '',\n        filesize int(11) NOT NULL default '0',\n        uid int(10) unsigned NOT NULL,\n        status tinyint unsigned NOT NULL, \n        author varchar(128) NOT NULL default '',\n        title varchar(128) NOT NULL default '',\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_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':
      db_query("CREATE TABLE {asset} (\n        aid SERIAL,\n        type varchar(32) NOT NULL default '',\n        dirname varchar(128) NOT NULL default '',\n        extension varchar(128) NOT NULL default '',\n        filename varchar(255) NOT NULL default '',\n        filesize bigint NOT NULL default '0',\n        uid integer NOT NULL,\n        status smallint NOT NULL, \n        author varchar(128) NOT NULL default '',\n        title varchar(128) NOT NULL default '',\n        description text NOT NULL,\n        PRIMARY KEY (aid)\n      )");
      db_query("CREATE TABLE {asset_node} (\n        aid integer NOT NULL,\n        nid integer NOT NULL,\n        refs integer NOT NULL default '0',\n        PRIMARY KEY (aid,nid)\n      )");
      db_query("CREATE TABLE {asset_role} (\n        aid integer NOT NULL,\n        rid integer NOT NULL,\n        status smallint NOT NULL default '0',\n        PRIMARY KEY (aid,rid)\n      )");
      break;
  }
  drupal_set_message(t('Asset tables have been configured.'));
}