You are here

function advagg_update_6101 in Advanced CSS/JS Aggregation 6

Update 6101 - Move data column to cache table.

File

./advagg.install, line 753
Handles Advanced Aggregation installation and upgrade tasks.

Code

function advagg_update_6101() {
  $ret = array();

  // Make sure the advagg_set_file_data function is available.
  drupal_load('module', 'advagg');

  // Create cache table.
  $schema['cache_advagg_files_data'] = drupal_get_schema_unprocessed('system', 'cache');
  $schema['cache_advagg_files_data']['description'] = t('Cache table for Advanced CSS/JS Aggregation. Used to keep data about files.');
  db_create_table($ret, 'cache_advagg_files_data', $schema['cache_advagg_files_data']);

  // Migrate data.
  $results = db_query("SELECT filename_md5, data FROM {advagg_files}");
  while ($row = db_fetch_array($results)) {
    if (empty($row['data'])) {
      continue;
    }
    $data = unserialize($row['data']);
    advagg_set_file_data($row['filename_md5'], $data);
  }

  // Drop in data column.
  db_drop_field($ret, 'advagg_files', 'data');
  return $ret;
}