I have created a D8 custom field that extends FieldBaseItem
. It is already in use storing data.
How do I get the schema updated in the database, for an existing field?
What I’ve done:
I have added a new column by adding to propertyDefinitions
and schema()
accordingly.
Here’s an example schema. Let’s say I just added the admin
column.
/** * {@inheritdoc} */ public static function schema(FieldStorageDefinitionInterface $ field_definition) { $ schema = [ 'columns' => [ 'state' => [ 'type' => 'varchar', 'length' => 2 ], 'admin' => [ 'type' => 'int', 'size' => 'tiny' ], ...
I’ve found posts on how to do this in hook_update_N
in D7, but it’s unclear how to do this in D8.