Since, hook_schema_alter() is removed from Drupal 8, how to alter any existing schema of some module in Drupal 8?
I have used mymodule_update_8201
(hook_update_N()
) function in my .install file
use Drupal\Core\Database\Database;
/**
* Implements hook_update_N()().
*/
function mymodule_update_8201() {
$spec = array(
'type' => 'varchar',
'description' => "New Col",
'length' => 20,
'not null' => FALSE,
);
$schema = Database::getConnection()->schema();
$schema->addField('mytable', 'newcol', $spec);
return $schema;
}
But no new field or column gets added into my existing table. Is their any other way to achieve this?