You are here

deploy.install in Deploy - Content Staging 7.3

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

Deploy module installation functions.

File

deploy.install
View source
<?php

/**
 * @file
 * Deploy module installation functions.
 */

/**
 * Implements hook_schema().
 *
 * @todo
 *   Add indexes.
 */
function deploy_schema() {
  $schema = array();
  $schema['deploy_plans'] = array(
    'description' => 'Base table holding deployment plans.',
    'export' => array(
      'api' => array(
        'owner' => 'deploy',
        'api' => 'deploy_plans',
        'minimum_version' => 1,
        'current_version' => 1,
      ),
      'key' => 'name',
      'key name' => 'Name',
      'primary key' => 'pid',
      'identifier' => 'plan',
      'object factory' => 'deploy_plan_create',
      'load callback' => 'deploy_plan_load',
      'load all callback' => 'deploy_plan_load_all',
      'default hook' => 'deploy_plans_default',
    ),
    'fields' => array(
      'pid' => array(
        'description' => 'Serial id for this plan. Only used for internal lookups.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'no export' => TRUE,
      ),
      'name' => array(
        'description' => 'Machine-readable name for this plan.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
      ),
      'title' => array(
        'description' => 'Administrative title for this plan.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
      ),
      'description' => array(
        'description' => 'Administrative description for this plan.',
        'type' => 'text',
        'size' => 'medium',
        'not null' => TRUE,
      ),
      'debug' => array(
        'description' => 'Debug mode.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'aggregator_plugin' => array(
        'description' => 'Aggregator plugin used for this plan.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
      ),
      'aggregator_config' => array(
        'description' => "Serialized configuration data this plan's aggregator plugin.",
        'type' => 'text',
        'size' => 'big',
        'not null' => TRUE,
        'serialize' => TRUE,
      ),
      'fetch_only' => array(
        'description' => 'Indicates if this plan is fetch-only.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'processor_plugin' => array(
        'description' => 'Processor plugin used for this plan.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'processor_config' => array(
        'description' => "Serialized configuration data this plan's processor plugin.",
        'type' => 'text',
        'size' => 'big',
        'not null' => TRUE,
        'serialize' => TRUE,
      ),
      'endpoints' => array(
        'description' => 'Serialized array of all endpoints for this plan.',
        'type' => 'text',
        'size' => 'big',
        'not null' => TRUE,
        'serialize' => TRUE,
      ),
      'dependency_plugin' => array(
        'description' => 'Dependency plugin used for this plan.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'pid',
    ),
    'indexes' => array(
      'name' => array(
        'name',
      ),
      'fetch_only' => array(
        'fetch_only',
      ),
      'aggregator_plugin' => array(
        'aggregator_plugin',
      ),
    ),
  );
  $schema['deploy_endpoints'] = array(
    'description' => 'Base table holding deployment endpoints.',
    'export' => array(
      'api' => array(
        'owner' => 'deploy',
        'api' => 'deploy_endpoints',
        'minimum_version' => 1,
        'current_version' => 1,
      ),
      'key' => 'name',
      'key name' => 'Name',
      'primary key' => 'eid',
      'identifier' => 'endpoint',
      'object factory' => 'deploy_endpoint_create',
      'load callback' => 'deploy_endpoint_load',
      'load all callback' => 'deploy_endpoint_load_all',
      'default hook' => 'deploy_endpoints_default',
    ),
    'fields' => array(
      'eid' => array(
        'description' => 'Serial id for this endpoint. Only used for internal lookups.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'no export' => TRUE,
      ),
      'name' => array(
        'description' => 'Machine-readable name for this endpoint.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
      ),
      'title' => array(
        'description' => 'Administrative title for this endpoint.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
      ),
      'description' => array(
        'description' => 'Administrative description for this endpoint.',
        'type' => 'text',
        'size' => 'medium',
        'not null' => TRUE,
      ),
      'debug' => array(
        'description' => 'Debug mode.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'authenticator_plugin' => array(
        'description' => 'Authenticator plugin used for this endpoint.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
      ),
      'authenticator_config' => array(
        'description' => "Serialized configuration data for this endpoint's authenticator plugin.",
        'type' => 'text',
        'size' => 'big',
        'not null' => TRUE,
        'serialize' => TRUE,
      ),
      'service_plugin' => array(
        'description' => 'Service plugin used for this endpoint.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
      ),
      'service_config' => array(
        'description' => "Serialized configuration data this endpoint's service plugin.",
        'type' => 'text',
        'size' => 'big',
        'not null' => TRUE,
        'serialize' => TRUE,
      ),
    ),
    'primary key' => array(
      'eid',
    ),
    'indexes' => array(
      'name' => array(
        'name',
      ),
    ),
  );
  $schema['deploy_deployments'] = array(
    'description' => 'Log of all deployments pushed from this site.',
    'fields' => array(
      'did' => array(
        'description' => 'Deployment ID.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'no export' => TRUE,
      ),
      'plan_name' => array(
        'description' => 'Plan name responsible for this deployment.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
      ),
      'uuid' => array(
        'description' => 'UUID key for tracking a deployment.',
        'type' => 'char',
        'length' => 36,
        'not null' => TRUE,
      ),
      'lid' => array(
        'description' => 'Pointer to the latest log entry for this deployment (deploy_log.lid).',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'did',
    ),
    'indexes' => array(
      'uuid' => array(
        'uuid',
      ),
      'plan_name' => array(
        'plan_name',
      ),
      'uuid_plan_name' => array(
        'uuid',
        'plan_name',
      ),
    ),
  );
  $schema['deploy_log'] = array(
    'description' => 'Log of all status updates for a deployment.',
    'fields' => array(
      'lid' => array(
        'description' => 'Log ID.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'no export' => TRUE,
      ),
      'uuid' => array(
        'description' => 'UUID reference to a deployment (deploy_deployments.uuid).',
        'type' => 'char',
        'length' => 36,
        'not null' => TRUE,
      ),
      'status' => array(
        'description' => 'A status code for the deployment.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 1,
      ),
      'timestamp' => array(
        'description' => 'Timestamp when this log entry was updated.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'message' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => 'Complementary message, for example the exception in case of a failure.',
      ),
    ),
    'primary key' => array(
      'lid',
    ),
    'indexes' => array(
      'uuid' => array(
        'uuid',
      ),
    ),
  );
  $schema['deploy_manager_entities'] = array(
    'description' => 'Holds entities to be deployed for managed plans.',
    'fields' => array(
      'dme_id' => array(
        'description' => 'The unique identifier for this record.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'plan_name' => array(
        'description' => 'The name of the deployment plan this item applies to.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'entity_type' => array(
        'description' => 'The type of entity, for example "node", "user".',
        'type' => 'varchar',
        'length' => 50,
        'not null' => TRUE,
      ),
      'entity_id' => array(
        'description' => 'The entity ID to be deployed.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'revision_id' => array(
        'description' => 'The entity revision ID to be deployed.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'timestamp' => array(
        'description' => 'The unix timestamp indicating when this item was added to the deployment plan.',
        'type' => 'numeric',
        'precision' => 16,
        'scale' => 4,
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'dme_id',
    ),
    'unique keys' => array(
      'record' => array(
        'plan_name',
        'entity_type',
        'entity_id',
        'revision_id',
      ),
    ),
    'indexes' => array(
      'timstamp' => array(
        'timestamp',
      ),
      'entity_record' => array(
        'entity_type',
        'entity_id',
      ),
      'entity_revision' => array(
        'entity_type',
        'revision_id',
      ),
    ),
  );
  return $schema;
}

/**
 * Convert timestamp for deploy_manager_entities to float for more precision.
 */
function deploy_update_7001(&$sandbox) {
  $spec = array(
    'description' => 'The unix timestamp indicating when this item was added to the deployment plan.',
    'type' => 'numeric',
    'precision' => 16,
    'scale' => 4,
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  );
  db_change_field('deploy_manager_entities', 'timestamp', 'timestamp', $spec);

  // Now we add the new index so MySQL doesn't whinge.
  db_add_index('deploy_manager_entities', 'timstamp', array(
    'timestamp',
  ));
}

/**
 * Add new fields to the 'deploy_plans' table.
 */
function deploy_update_7002() {
  if (!db_field_exists('deploy_plans', 'dependency_plugin')) {
    db_add_field('deploy_plans', 'dependency_plugin', array(
      'description' => 'Dependency plugin used for this plan.',
      'type' => 'varchar',
      'length' => 128,
      'not null' => TRUE,
      'default' => '',
    ));
  }
}

/**
 * Add serial primary key to deploy_manager_entities.
 */
function deploy_update_7003(&$sandbox) {
  $table = 'deploy_manager_entities';
  $spec = array(
    'description' => 'The unique identifier for this record.',
    'type' => 'serial',
    'unsigned' => TRUE,
    'not null' => TRUE,
  );
  $new_keys = array(
    'primary key' => array(
      'dme_id',
    ),
    'unique keys' => array(
      'record' => array(
        'plan_name',
        'entity_type',
        'entity_id',
        'revision_id',
      ),
    ),
    'indexes' => array(
      'entity_record' => array(
        'entity_type',
        'entity_id',
      ),
      'entity_revision' => array(
        'entity_type',
        'revision_id',
      ),
    ),
  );
  db_drop_primary_key('deploy_manager_entities');
  db_add_field($table, 'dme_id', $spec, $new_keys);
}

/**
 * Encrypt existing endpoints username & password.
 */
function deploy_update_7004() {
  if (_deploy_encrypt_endpoints()) {
    return t("All Endpoints username & password encrypted successfully.");
  }
  return t("Updated skipped: This update only applies when using the Encrypt module.");
}

/**
 * Implements hook_install().
 */
function deploy_install() {
  _deploy_encrypt_endpoints();
}

/**
 * Implements hook_uninstall().
 */
function deploy_uninstall() {
  variable_del('deploy_encryption_state');
}

Functions

Namesort descending Description
deploy_install Implements hook_install().
deploy_schema Implements hook_schema().
deploy_uninstall Implements hook_uninstall().
deploy_update_7001 Convert timestamp for deploy_manager_entities to float for more precision.
deploy_update_7002 Add new fields to the 'deploy_plans' table.
deploy_update_7003 Add serial primary key to deploy_manager_entities.
deploy_update_7004 Encrypt existing endpoints username & password.