content_deploy-1.0.1/content_deploy.install

content_deploy.install
<?php
/**
 * @file
 * Install, update and uninstall functions for the content_deploy module.
 */
 use Drupal\Core\Database\Database;

/**
 * Implements hook_install().
 */
/*function content_deploy_install(){
  //Create the content snapshot.
  $cs_snapshoot = Drupal::service('content_deploy.snaphoshot');
  $cs_snapshoot->snapshot();
}*/

/**
 * Implements hook_schema().
 */
function content_deploy_schema() {
  // Content Deploy Table - DB Snapshot.
  $schema['cs_db_snapshot'] = [
    'description' => 'The base table for content data.',
      'fields' => [
      'collection' => [
        'description' => 'Primary Key: Content object collection.',
        'type' => 'varchar_ascii',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ],
      'name' => [
        'description' => 'Primary Key: Content object name.',
        'type' => 'varchar_ascii',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ],
      'data' => [
        'description' => 'A serialized content object data.',
        'type' => 'blob',
        'not null' => FALSE,
        'size' => 'big',
      ],
    ],
    'primary key' => ['collection', 'name'],
  ];
  // Content Deploy Logs Table
  $schema['cs_logs'] = [
    'description' => 'Table that contains content_deploy logs.',
    'fields' => [
      'csid' => [
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique content_deploy event ID.',
      ],
      'uid' => [
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The {users}.uid of the user who triggered the event.',
      ],
      'type' => [
        'type' => 'varchar_ascii',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Type of log message, for example "Import" or "Export"',
      ],
      'message' => [
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => 'Text of log message to be passed into the t() function.',
      ],
      'variables' => [
        'type' => 'blob',
        'not null' => TRUE,
        'size' => 'big',
        'description' => 'Serialized array of variables that match the message string and that is passed into the t() function.',
      ],
      'severity' => [
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'The severity level of the event; ranges from 0 (Emergency) to 7 (Debug)',
      ],
      'link' => [
        'type' => 'text',
        'not null' => FALSE,
        'description' => 'Link to view the result of the event.',
      ],
      'location'  => [
        'type' => 'text',
        'not null' => TRUE,
        'description' => 'URL of the origin of the event.',
      ],
      'referer' => [
        'type' => 'text',
        'not null' => FALSE,
        'description' => 'URL of referring page.',
      ],
      'hostname' => [
        'type' => 'varchar_ascii',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Hostname of the user who triggered the event.',
      ],
      'timestamp' => [
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Unix timestamp of when event occurred.',
      ],
    ],
    'primary key' => ['csid'],
    'indexes' => [
      'type' => ['type'],
      'uid' => ['uid'],
      'severity' => ['severity'],
    ],
  ];

  // Content Deploy Node Export Logs Table
  $schema['cd_node_export_logs'] = [
    'description' => 'Table that contains content_deploy node export logs.',
    'fields' => [
      'node_uuid' => [
        'type' => 'text',
        'not null' => TRUE,
        'description' => 'UUID of node which exported.',
      ],
      'user_uuid' => [
        'type' => 'text',
        'not null' => TRUE,
        'description' => 'UUID of user who triggered the export.',
      ],
      'timestamp' => [
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Unix timestamp of when export event occurred.',
      ],
      'data' => [
        'type' => 'blob',
        'not null' => FALSE,
        'size' => 'big',
        'description' => 'Serialized array containing data related to export.',
      ],
    ]
  ];

  // Table to store the data related to auto deployment
  $schema['cd_auto_nodes_export'] = [
    'description' => 'Table that contains cd_auto_nodes_export data.',
    'fields' => [
      'node_uuid' => [
        'type' => 'text',
        'not null' => TRUE,
        'description' => 'UUID of node which exported.',
      ],
      'node_target_status' => [
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'description' => 'Status selected by user for the node which will be set on deployment.',
      ],
      'target_environment' => [
        'type' => 'text',
        'not null' => TRUE,
        'description' => 'Target Environment for the exported node.',
      ],
      'deployment_time' => [
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Unix timestamp of when nodes should be auto deployed.',
      ],
      'user_uuid' => [
        'type' => 'text',
        'not null' => TRUE,
        'description' => 'UUID of user who created the auto export event.',
      ],
      'created' => [
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Unix timestamp of when user created the auto export event.',
      ],
      'deployment_status' => [
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Status of deployment i.e. whether its processed or not.',
      ],
    ]
  ];
  return $schema;
}

/**
 * Update function for enable the action node export.
 */
function content_deploy_update_8001() {
  $config_installer = \Drupal::service('config.installer');
  $config_installer->installDefaultConfig('module', 'content_deploy');
}

/**
 * Update function to create the custom cd_node_export_logs table.
 */
function content_deploy_update_8002() {
  $schema = Database::getConnection()->schema();
  $table_name = 'cd_node_export_logs';

  $table_exists = $schema->tableExists($table_name);
  if (!$table_exists) {
    $table_schema = [
      'description' => 'Table that contains content_deploy node export logs.',
      'fields' => [
        'node_uuid' => [
          'type' => 'text',
          'not null' => TRUE,
          'description' => 'UUID of node which exported.',
        ],
        'user_uuid' => [
          'type' => 'text',
          'not null' => TRUE,
          'description' => 'UUID of user who triggered the export.',
        ],
        'timestamp' => [
          'type' => 'int',
          'not null' => TRUE,
          'default' => 0,
          'description' => 'Unix timestamp of when export event occurred.',
        ],
        'data' => [
          'type' => 'blob',
          'not null' => FALSE,
          'size' => 'big',
          'description' => 'Serialized array containing data related to export.',
        ],
      ]
    ];
    $schema->createTable($table_name, $table_schema);
  }
}

/**
 * Update function to create the custom cd_auto_nodes_export table.
 */
function content_deploy_update_8003() {
  $schema = Database::getConnection()->schema();
  $table_name = 'cd_auto_nodes_export';

  $table_exists = $schema->tableExists($table_name);
  if (!$table_exists) {
    $table_schema = [
      'description' => 'Table that contains cd_auto_nodes_export data.',
      'fields' => [
        'node_uuid' => [
          'type' => 'text',
          'not null' => TRUE,
          'description' => 'UUID of node which exported.',
        ],
        'node_target_status' => [
          'type' => 'int',
          'size' => 'tiny',
          'not null' => TRUE,
          'description' => 'Status selected by user for the node which will be set on deployment.',
        ],
        'target_environment' => [
          'type' => 'text',
          'not null' => TRUE,
          'description' => 'Target Environment for the exported node.',
        ],
        'deployment_time' => [
          'type' => 'int',
          'not null' => TRUE,
          'default' => 0,
          'description' => 'Unix timestamp of when nodes should be auto deployed.',
        ],
        'user_uuid' => [
          'type' => 'text',
          'not null' => TRUE,
          'description' => 'UUID of user who created the auto export event.',
        ],
        'created' => [
          'type' => 'int',
          'not null' => TRUE,
          'default' => 0,
          'description' => 'Unix timestamp of when user created the auto export event.',
        ],
        'deployment_status' => [
          'type' => 'int',
          'size' => 'tiny',
          'not null' => TRUE,
          'default' => 0,
          'description' => 'Status of deployment i.e. whether its processed or not.',
        ],
      ]
    ];
    $schema->createTable($table_name, $table_schema);
  }
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc