You are here

function uc_file_install in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_file/uc_file.install \uc_file_install()

File

uc_file/uc_file.install, line 3

Code

function uc_file_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':
      db_query("CREATE TABLE {uc_files} (\n        `fid` mediumint(9) NOT NULL,\n        `filename` varchar(255) NOT NULL,\n        KEY fid (fid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {uc_file_products} (\n        `pfid` mediumint(9) NOT NULL,\n        `fid` mediumint(9) NOT NULL,\n        `model` varchar(255) default NULL,\n        `description` VARCHAR(255) default NULL,\n        `shippable` BOOL NOT NULL,\n        KEY pfid (pfid),\n        KEY fid (fid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {uc_file_users} (\n        `fid` mediumint(9) NOT NULL,\n        `uid` mediumint(9) NOT NULL,\n        `pfid` mediumint(9) default NULL,\n        `file_key` varchar(32) NOT NULL,\n        `granted` int(11) NOT NULL,\n        `accessed` smallint(5) unsigned NOT NULL default 0,\n        `addresses` text,\n        KEY fid (fid),\n        KEY uid (uid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {uc_files} (\n        fid serial NOT NULL,\n        filename varchar(255) NOT NULL,\n        PRIMARY KEY (fid)\n        );");
      db_query("CREATE INDEX {uc_files}_fid ON {uc_files} (fid)");
      db_query("CREATE TABLE {uc_file_products} (\n        pfid integer NOT NULL,\n        fid integer NOT NULL,\n        model varchar(255) default NULL,\n        description varchar(255) default NULL,\n        shippable boolean NOT NULL\n        );");
      db_query("CREATE INDEX {uc_file_products}_pfid ON {uc_file_products} (pfid)");
      db_query("CREATE INDEX {uc_file_products}_fid ON {uc_file_products} (fid)");
      db_query("CREATE TABLE {uc_file_users} (\n        fid integer NOT NULL,\n        uid integer NOT NULL,\n        pfid integer default NULL,\n        key varchar(32) NOT NULL,\n        granted integer NOT NULL,\n        accessed smallint_unsigned NOT NULL default 0,\n        addresses text\n        );");
      db_query("CREATE INDEX {uc_file_users}_pfid ON {uc_file_users} (pfid)");
      db_query("CREATE INDEX {uc_file_users}_uid ON {uc_file_users} (uid)");
      break;
  }
}