You are here

function filefield_paths_update_7103 in File (Field) Paths 7

Add origname field to {file_managed}.

File

./filefield_paths.install, line 69
Install, update and uninstall functions for the File (Field) Paths module.

Code

function filefield_paths_update_7103() {

  // Clean-up an unused variable.
  variable_del('filefield_paths_schema_version');

  // Add origname field to {file_managed}, and populate with the current
  // filenames.
  if (!db_field_exists('file_managed', 'origname')) {
    db_add_field('file_managed', 'origname', array(
      'description' => 'Original name of the file with no path components. Used by the filefield_paths module.',
      'type' => 'varchar',
      'length' => 255,
      'not null' => TRUE,
      'default' => '',
    ));
  }
  db_update('file_managed')
    ->expression('origname', 'filename')
    ->condition('origname', '')
    ->execute();
}