You are here

function patchinfo_update_8201 in PatchInfo 8.2

Adds source_module field to patchinfo database table.

File

./patchinfo.install, line 62
Install, update, and uninstall functions for the Patch Info module.

Code

function patchinfo_update_8201() {
  $table = 'patchinfo';
  $field = 'source_module';
  $spec = [
    'description' => 'Machine readable name of source module',
    'type' => 'varchar',
    'length' => '50',
    'not null' => TRUE,
    'initial' => '',
  ];
  $database_connection = Database::getConnection();
  if ($database_connection) {
    $schema = $database_connection
      ->schema();
    if ($schema) {
      if ($schema
        ->tableExists($table)) {
        if (!$schema
          ->fieldExists($table, $field)) {
          $schema
            ->addField($table, $field, $spec);
          $database_connection
            ->delete($table)
            ->condition('source_module', '')
            ->execute();
        }
      }
    }
  }
}