You are here

function backup_migrate_update_7303 in Backup and Migrate 8.3

Same name and namespace in other branches
  1. 7.3 backup_migrate.install \backup_migrate_update_7303()

Add a serial id field to all tables to allow them to be ctools exportable.

File

./backup_migrate.install, line 609
Install hooks for Backup and Migrate.

Code

function backup_migrate_update_7303() {
  foreach (array(
    'backup_migrate_sources' => 'source_id',
    'backup_migrate_destinations' => 'destination_id',
    'backup_migrate_schedules' => 'schedule_id',
    'backup_migrate_profiles' => 'profile_id',
  ) as $table => $id) {
    db_drop_primary_key($table);
    db_change_field($table, $id, 'machine_name', array(
      'type' => 'varchar',
      'length' => 32,
      'not null' => TRUE,
    ));
    db_add_field($table, $id, array(
      'type' => 'serial',
      'unsigned' => TRUE,
      'not null' => TRUE,
      'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
      'no export' => TRUE,
    ), array(
      'primary key' => array(
        $id,
      ),
    ));
  }
  foreach (array(
    'backup_migrate_sources',
    'backup_migrate_destinations',
  ) as $table) {
    db_change_field($table, 'type', 'subtype', array(
      'type' => 'varchar',
      'length' => 32,
      'not null' => TRUE,
    ));
  }
}