You are here

function farm_asset_update_7003 in farmOS 7

Change the asset active property to an archived timestamp.

File

modules/farm/farm_asset/farm_asset.install, line 171
Farm asset install.

Code

function farm_asset_update_7003(&$sandbox) {

  // Add the new archived field and index.
  $new_field = array(
    'description' => 'Timestamp when the asset was last archived',
    'type' => 'int',
  );
  $new_keys = array(
    'indexes' => array(
      'archived' => array(
        'archived',
      ),
    ),
  );
  db_add_field('farm_asset', 'archived', $new_field, $new_keys);

  // Populate the archived field of inactive assets with the value from the
  // asset's changed field.
  db_query('UPDATE {farm_asset} SET archived = changed WHERE active = 0');

  // Drop the active field.
  db_drop_field('farm_asset', 'active');
}