You are here

deploy.install in Deploy - Content Staging 5

Same filename and directory in other branches
  1. 8 deploy.install
  2. 6 deploy.install
  3. 7.3 deploy.install
  4. 7.2 deploy.install

File

deploy.install
View source
<?php

/**
 * Implementation of hook_install().
 */
function deploy_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {deploy_plan} (\n        pid int unsigned NOT NULL default '0',\n        name varchar(50) NOT NULL,\n        description text,\n        PRIMARY KEY (pid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {deploy_plan_items} (\n        iid int unsigned NOT NULL default '0',\n        pid int unsigned NOT NULL default '0',\n        module varchar(50) NOT NULL,\n        description varchar(75),\n        weight int NOT NULL default '0',\n        data longtext NOT NULL,\n        uid int NOT NULL,\n        ts int NOT NULL,\n        PRIMARY KEY (iid, pid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {deploy_servers} (\n        sid int unsigned NOT NULL default '0',\n        description varchar(100),\n        url varchar(100),\n        api_key varchar(32),\n        PRIMARY KEY (sid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {deploy_log} (\n        dlid int unsigned NOT NULL,\n        plan varchar(50) NOT NULL,\n        server varchar(100) NOT NULL,\n        username varchar(60) NOT NULL,\n        ts int NOT NULL,\n        PRIMARY KEY (dlid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {deploy_log_details} (\n        dldid int unsigned NOT NULL,\n        dlid int unsigned NOT NULL, \n        module varchar(50) NOT NULL,\n        description varchar(75) NOT NULL,\n        result varchar(25) NOT NULL,\n        message varchar(255) NOT NULL,\n        PRIMARY KEY (dldid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {deploy_plan} (\n        pid int_unsigned NOT NULL default '0',\n        description text,\n        name varchar(50) NOT NULL,\n        PRIMARY KEY (pid)\n      )");
      db_query("CREATE TABLE {deploy_plan_items} (\n        iid int_unsigned NOT NULL default '0',\n        pid int_unsigned NOT NULL default '0',\n        module varchar(50) NOT NULL,\n        description varchar(75),\n        weight int NOT NULL default '0',\n        data text NOT NULL,\n        uid int NOT NULL,\n        ts int NOT NULL,\n        PRIMARY KEY (iid, pid)\n      )");
      db_query("CREATE TABLE {deploy_servers} (\n        sid int_unsigned NOT NULL default '0',\n        description varchar(100),\n        url varchar(100),\n        api_key varchar(32),\n        PRIMARY KEY (sid)\n      )");
      db_query("CREATE TABLE {deploy_log} (\n        dlid int_unsigned NOT NULL,\n        plan varchar(50) NOT NULL,\n        server varchar(100) NOT NULL,\n        username varchar(60) NOT NULL,\n        ts int NOT NULL,\n        PRIMARY KEY (dlid)\n      )");
      db_query("CREATE TABLE {deploy_log_details} (\n        dldid int_unsigned NOT NULL,\n        dlid int_unsigned NOT NULL, \n        module varchar(50) NOT NULL,\n        description varchar(75) NOT NULL,\n        result varchar(25) NOT NULL,\n        message varchar(255) NOT NULL,\n        PRIMARY KEY (dldid)\n      )");
      break;
  }
}
function deploy_update_1() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("ALTER TABLE {deploy_plan} ADD description text");
      $ret[] = update_sql("ALTER TABLE {deploy_plan_items} ADD uid int NOT NULL");
      $ret[] = update_sql("ALTER TABLE {deploy_plan_items} ADD ts int NOT NULL");
      $ret[] = update_sql("CREATE TABLE {deploy_log} (\n        dlid int unsigned NOT NULL,\n        plan varchar(50) NOT NULL,\n        server varchar(100) NOT NULL,\n        username varchar(60) NOT NULL,\n        ts int NOT NULL,\n        PRIMARY KEY (dlid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      $ret[] = update_sql("CREATE TABLE {deploy_log_details} (\n        dldid int unsigned NOT NULL,\n        dlid int unsigned NOT NULL, \n        module varchar(50) NOT NULL,\n        description varchar(75) NOT NULL,\n        result varchar(25) NOT NULL,\n        message varchar(255) NOT NULL,\n        PRIMARY KEY (dldid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      break;
    case 'pgsql':
      db_add_column($ret, 'deploy_plan', 'description', 'text');
      db_add_column($ret, 'deploy_plan_items', 'uid', 'int', array(
        'not null' => TRUE,
      ));
      db_add_column($ret, 'deploy_plan_items', 'ts', 'int', array(
        'not null' => TRUE,
      ));
      $ret[] = update_sql("CREATE TABLE {deploy_log} (\n        dlid int_unsigned NOT NULL,\n        plan varchar(50) NOT NULL,\n        server varchar(100) NOT NULL,\n        username varchar(60) NOT NULL,\n        ts int NOT NULL,\n        PRIMARY KEY (dlid)\n      )");
      $ret[] = update_sql("CREATE TABLE {deploy_log_details} (\n        dldid int_unsigned NOT NULL,\n        dlid int_unsigned NOT NULL, \n        module varchar(50) NOT NULL,\n        description varchar(75) NOT NULL,\n        result varchar(25) NOT NULL,\n        message varchar(255) NOT NULL,\n        PRIMARY KEY (dldid)\n      )");
      break;
  }
  return $ret;
}

/**
 * Implementation of hook_uninstall().
 */
function deploy_uninstall() {
  db_query('DROP TABLE {deploy_log_details}');
  db_query('DROP TABLE {deploy_log}');
  db_query('DROP TABLE {deploy_plan_items}');
  db_query('DROP TABLE {deploy_servers}');
  db_query('DROP TABLE {deploy_plan}');
}

Functions

Namesort descending Description
deploy_install Implementation of hook_install().
deploy_uninstall Implementation of hook_uninstall().
deploy_update_1