You are here

media_acquiadam.install in Media: Acquia DAM 7

Same filename and directory in other branches
  1. 8 media_acquiadam.install

Drupal install related hooks.

File

media_acquiadam.install
View source
<?php

/**
 * @file
 * Drupal install related hooks.
 */

/**
 * Implements hook_install().
 */
function media_acquiadam_install() {
  if (!db_field_exists('file_managed', 'acquiadam_id')) {
    $schema = drupal_get_schema('file_managed');
    $indexes = [
      'acquiadam_id' => $schema['indexes']['acquiadam_id'],
      'fid_acquiadam_id' => $schema['indexes']['fid_acquiadam_id'],
    ];
    db_add_field('file_managed', 'acquiadam_id', $schema['fields']['acquiadam_id'], [
      'indexes' => $indexes,
    ]);
  }
}

/**
 * Implements hook_uninstall().
 */
function media_acquiadam_uninstall() {
  $del = [
    'media_acquiadam_client_id',
    'media_acquiadam_client_secret',
    'media_acquiadam_background_user',
    'media_acquiadam_background_pass',
    'media_acquiadam_client_mode',
    'media_acquiadam_cache_expiration',
    'media_acquiadam_unused_expiration',
    'media_acquiadam_extension_overrides',
  ];
  foreach ($del as $key) {
    variable_del($key);
  }
  if (db_field_exists('file_managed', 'acquiadam_id')) {
    $schema = drupal_get_schema('file_managed');
    db_drop_field('file_managed', 'acquiadam_id');
    db_drop_index('file_managed', 'fid_acquiadam_id');
  }
}

/**
 * Implements hook_schema().
 */
function media_acquiadam_schema() {
  $schema = [];
  $schema['acquiadam_asset_cache'] = [
    'description' => st('Locally cached Acquia DAM asset information.'),
    'fields' => [
      'asset_id' => [
        'description' => st('The Acquia DAM asset identifier.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
      'type' => [
        'description' => st('The machine name of the asset type.'),
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ],
      'data' => [
        'type' => 'blob',
        'size' => 'big',
        'not null' => TRUE,
        'description' => 'Serialized data containing the asset properties that do not warrant a dedicated column.',
      ],
      'created' => [
        'description' => 'The Unix timestamp when the asset was created.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'unsigned' => TRUE,
      ],
      'changed' => [
        'description' => 'The Unix timestamp when the asset was most recently saved.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'unsigned' => TRUE,
      ],
      'expiration' => [
        'description' => 'The Unix timestamp when the asset is set to expire.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
        'unsigned' => TRUE,
      ],
    ],
    'indexes' => [
      'created' => [
        'created',
      ],
      'changed' => [
        'changed',
      ],
      'expiration' => [
        'expiration',
      ],
    ],
    'unique keys' => [],
    'primary key' => [
      'asset_id',
    ],
  ];
  return $schema;
}