<?php
/**
 * @file
 * Database table schema definitions, database updates.
 */

/**
 * Implements hook_schema().
 */
function bassets_client_schema() {
  $schema['bassets_files'] = array(
    'fields' => array(
      'uuid' => array(
        'description' => 'The uuid of the file. See {file_managed}.uuid.',
        'type'        => 'varchar',
        'length'      => 255,
        'not null'    => TRUE,
      ),
      'bassets_server' => array(
        'description' => 'Connection name of the Bassets server. See {services_client_connection_id}.name.',
        'type' => 'char',
        'length' => '36',
        'not null'    => TRUE,
      ),
    ),
    'primary key' => array('uuid'),
    'foreign keys' => array(
      'file_uuid' => array(
        'table' => 'file_managed',
        'columns' => array('uuid' => 'uuid'),
      ),
      'file_provider' => array(
        'table' => 'services_client_connection_id',
        'columns' => array('bassets_server' => 'name'),
      ),
    ),
  );
  return $schema;
}

/**
 * Implements hook_install().
 */
function bassets_client_install() {
  variable_set('bassets_sw_base64_deliver', '_bassets_client_fetch_file_content');
}

/**
 * The feature bassets_client_media has a modified version of the view.
 */
function _bassets_client_disable_media_default() {
}

/**
 * Removed.
 */
function bassets_client_update_7001() {
}

/**
 * Deletes 'bassets_client_scc' from the system table.
 */
function bassets_client_update_7002() {
  db_delete('system')->condition('name', 'bassets_client_scc')->execute();
}

/**
 * Reverts the image style 'media_thumbnail'.
 */
function bassets_client_update_7003() {
  image_default_style_revert('media_thumbnail');
}
