You are here

function acquia_contenthub_update_8202 in Acquia Content Hub 8

Updates the Entities Tracking Table to include exported entities.

File

./acquia_contenthub.install, line 131
Install, update and uninstall functions for the acquia_contenthub module.

Code

function acquia_contenthub_update_8202() {
  define('ACQUIA_CONTENTHUB_ENTITY_TRACKING_TABLE', 'acquia_contenthub_entities_tracking');
  $schema = Database::getConnection()
    ->schema();

  // Rename Table.
  $schema
    ->renameTable('acquia_contenthub_imported_entities', ACQUIA_CONTENTHUB_ENTITY_TRACKING_TABLE);

  // Add/Change fields.
  $spec = [
    'description' => 'The status of an exported entity.',
    'type' => 'varchar',
    'default' => '',
    'not null' => TRUE,
    'length' => 36,
  ];
  $schema
    ->addField(ACQUIA_CONTENTHUB_ENTITY_TRACKING_TABLE, 'status_export', $spec);
  $spec = [
    'description' => 'The status of an imported entity.',
    'type' => 'varchar',
    'length' => 36,
    'default' => '',
    'not null' => TRUE,
  ];
  $schema
    ->changeField(ACQUIA_CONTENTHUB_ENTITY_TRACKING_TABLE, 'auto_update', 'status_import', $spec);
  $spec = [
    'description' => 'The CDF entity\'s modified field.',
    'type' => 'varchar',
    'default' => '',
    'not null' => TRUE,
    'length' => 36,
  ];
  $schema
    ->addField(ACQUIA_CONTENTHUB_ENTITY_TRACKING_TABLE, 'modified', $spec);

  // Updating data in the table.
  Database::getConnection()
    ->update(ACQUIA_CONTENTHUB_ENTITY_TRACKING_TABLE)
    ->fields([
    'status_import' => 'AUTO_UPDATE_ENABLED',
  ])
    ->condition('status_import', 'ENABLED', '=')
    ->execute();
  Database::getConnection()
    ->update(ACQUIA_CONTENTHUB_ENTITY_TRACKING_TABLE)
    ->fields([
    'status_import' => 'AUTO_UPDATE_DISABLED',
  ])
    ->condition('status_import', 'DISABLED', '=')
    ->execute();
}