You are here

function forum_access_update_8102 in Forum Access 8

Resize {forum_access}.rid and add primary key and index to the {forum_access} table.

File

./forum_access.install, line 76
Forum Access install file.

Code

function forum_access_update_8102(&$sandbox) {
  $new_schema = _forum_access_schema_8102();
  $schema = Database::getConnection()
    ->schema();

  // Drop the primary key and index that may have been created in update_8101.
  $schema
    ->dropPrimaryKey('forum_access');
  $schema
    ->dropIndex('forum_access', 'rid');

  // Adjust the 'rid' field width.
  $schema
    ->changeField('forum_access', 'rid', 'rid', $new_schema['forum_access']['fields']['rid']);

  // Add the primary key and index (again or for the first time).
  $schema
    ->addPrimaryKey('forum_access', [
    'tid',
    'rid',
  ]);
  $schema
    ->addIndex('forum_access', 'rid', [
    'rid',
  ], $new_schema['forum_access']);
}