You are here

function workflow_install in Workflow 5.2

Same name and namespace in other branches
  1. 8 workflow.install \workflow_install()
  2. 5 workflow.install \workflow_install()
  3. 6.2 workflow.install \workflow_install()
  4. 6 workflow.install \workflow_install()
  5. 7 workflow.install \workflow_install()

File

./workflow.install, line 3

Code

function workflow_install() {
  $result = array();
  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':
      $result[] = db_query(<<<QUERY
CREATE TABLE {workflow_states} (
  sid int(10) unsigned NOT NULL default '0',
  wid int(10) unsigned NOT NULL default '0',
  state varchar(255) NOT NULL default '',
  weight tinyint(4) NOT NULL default '0',
  sysid tinyint(4) NOT NULL default '0',
  status tinyint(4) NOT NULL default '1',
  PRIMARY KEY  (sid),
  KEY wid (wid),
  KEY sysid (sysid)
) /*!40100 DEFAULT CHARACTER SET utf8 */;
QUERY
);
      $result[] = db_query(<<<QUERY
CREATE TABLE {workflow_transitions} (
  tid int(10) unsigned NOT NULL default '0',
  sid int(10) unsigned NOT NULL default '0',
  target_sid int(10) unsigned NOT NULL default '0',
  roles varchar(255) default NULL,
  PRIMARY KEY  (tid),
  KEY sid (sid),
  KEY target_sid (target_sid)
) /*!40100 DEFAULT CHARACTER SET utf8 */;
QUERY
);
      $result[] = db_query(<<<QUERY
CREATE TABLE {workflows} (
  wid int(10) unsigned NOT NULL default '0',
  name varchar(255) NOT NULL default '',
  tab_roles varchar(60) NOT NULL default '',
  PRIMARY KEY  (wid)
) /*!40100 DEFAULT CHARACTER SET utf8 */;
QUERY
);
      $result[] = db_query(<<<QUERY
CREATE TABLE {workflow_type_map} (
  type varchar(255) NOT NULL default '',
  wid int(10) unsigned NOT NULL default '0',
  KEY type (type,wid)
) /*!40100 DEFAULT CHARACTER SET utf8 */;
QUERY
);
      $result[] = db_query(<<<QUERY
CREATE TABLE {workflow_node} (
  nid int(10) unsigned NOT NULL default '0',
  sid int(10) unsigned NOT NULL default '0',
  uid int(10) unsigned NOT NULL default '0',
  stamp int(11) unsigned NOT NULL default '0',
  PRIMARY KEY  (nid),
  KEY nid (nid,sid)
) /*!40100 DEFAULT CHARACTER SET utf8 */;
QUERY
);
      $result[] = db_query(<<<QUERY
CREATE TABLE {workflow_node_history} (
  hid int(10) unsigned NOT NULL auto_increment,
  nid int(10) unsigned NOT NULL default '0',
  old_sid int(10) unsigned NOT NULL default '0',
  sid int(10) unsigned NOT NULL default '0',
  uid int(10) unsigned NOT NULL default '0',
  stamp int(10) unsigned NOT NULL default '0',
  comment longtext,
  PRIMARY KEY (hid),
  KEY nid (nid,sid)
) /*!40100 DEFAULT CHARACTER SET utf8 */;
QUERY
);
      $result[] = db_query(<<<QUERY
CREATE TABLE {workflow_scheduled_transition} (
  nid int(10) unsigned NOT NULL default '0',
  old_sid int(10) unsigned NOT NULL default '0',
  sid int(10) unsigned NOT NULL default '0',
  scheduled int(10) unsigned NOT NULL default '0',
  comment longtext,
  KEY nid (nid)
) /*!40100 DEFAULT CHARACTER SET utf8 */;
QUERY
);
      break;
    case 'pgsql':
      $result[] = db_query(<<<QUERY
CREATE TABLE {workflow_states} (
  sid SERIAL,
  wid integer NOT NULL default '0',
  state varchar(255) NOT NULL default '',
  weight smallint NOT NULL default '0',
  sysid smallint NOT NULL default '0',
  status smallint NOT NULL default '1',
  PRIMARY KEY  (sid)
);
QUERY
);
      $result[] = db_query(<<<QUERY
CREATE INDEX {workflow_states}_wid_idx ON {workflow_states}(wid);
QUERY
);
      $result[] = db_query(<<<QUERY
CREATE INDEX {workflow_states}_sysid_idx ON {workflow_states}(sysid);
QUERY
);
      $result[] = db_query(<<<QUERY
CREATE TABLE {workflow_transitions} (
  tid SERIAL,
  sid integer NOT NULL default '0',
  target_sid integer NOT NULL default '0',
  roles varchar(60) default NULL,
  PRIMARY KEY  (tid)
);
QUERY
);
      $result[] = db_query(<<<QUERY
CREATE INDEX {workflow_transitions}_sid_idx ON {workflow_transitions}(sid);
QUERY
);
      $result[] = db_query(<<<QUERY
CREATE INDEX {workflow_transitions}_target_sid_idx ON {workflow_transitions}(target_sid);
QUERY
);
      $result[] = db_query(<<<QUERY
CREATE TABLE {workflows} (
  wid SERIAL,
  name varchar(255) NOT NULL default '',
  tab_roles varchar(60) NOT NULL default '',
  PRIMARY KEY  (wid)
);
QUERY
);
      $result[] = db_query(<<<QUERY
CREATE TABLE {workflow_type_map} (
  type varchar(255) NOT NULL default '',
  wid integer NOT NULL default '0'
);
QUERY
);
      $result[] = db_query(<<<QUERY
CREATE INDEX {workflow_type_map}_type_wid_idx ON {workflow_type_map}(type,wid);
QUERY
);
      $result[] = db_query(<<<QUERY
CREATE TABLE {workflow_node} (
  nid SERIAL,
  sid integer NOT NULL default '0',
  uid integer NOT NULL default '0',
  stamp integer NOT NULL default '0',
  PRIMARY KEY  (nid)
);
QUERY
);
      $result[] = db_query(<<<QUERY
CREATE INDEX {workflow_node}_nid_sid_idx ON {workflow_node}(nid,sid);
QUERY
);
      $result[] = db_query(<<<QUERY
CREATE TABLE {workflow_node_history} (
  hid serial,
  nid integer NOT NULL default '0',
  old_sid integer NOT NULL default '0',
  sid integer NOT NULL default '0',
  uid integer NOT NULL default '0',
  stamp integer NOT NULL default '0',
  comment text
);
QUERY
);
      $result[] = db_query(<<<QUERY
CREATE INDEX {workflow_node_history}_nid_sid_idx ON {workflow_node_history}(nid,sid);
QUERY
);
      $result[] = db_query(<<<QUERY
CREATE TABLE {workflow_scheduled_transition} (
  nid integer NOT NULL default '0',
  old_sid integer NOT NULL default '0',
  sid integer NOT NULL default '0',
  scheduled integer NOT NULL default '0',
  comment text
);
QUERY
);
      $result[] = db_query(<<<QUERY
CREATE INDEX {workflow_scheduled_transition}_nid_idx ON {workflow_scheduled_transition}(nid);
QUERY
);
      break;
  }
  if (count($result) != count(array_filter($result))) {
    drupal_set_message(t('Drupal was unable to install the database tables for the workflow module.'), 'error');
  }
}