Change record status: 
Project: 
Introduced in branch: 
8.7.x
Introduced in version: 
8.7.0
Description: 

The Schema::fieldSetDefault and Schema::fieldSetNoDefault methods have been deprecated in favor of using Schema::changeField method, in order to ensure more control to database schema changes.

While there is no current usage of the deprecated methods in core at the time of deprecation, its potential usage is most likely in update hooks, where it is now recommended to call changeField passing in a full field (column) specification for the changes needed to the database schema.

Before:

...
      $injected_database_connection->schema()->fieldSetDefault('mytable', 'field1', 0);
...
      $injected_database_connection->schema()->fieldSetNoDefault('mytable', 'field2');
...

After:

...
      $injected_database_connection->schema()->changeField('mytable', 'field1', 'field1', [
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
     ]);
...
      $injected_database_connection->schema()->changeField('mytable', 'field2', 'field2', [
        'type' => 'int',
        'not null' => TRUE,
     ]);
...
Impacts: 
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done

Comments

rivimey’s picture

Why would the API be made more difficult to use on purpose? I have an update hook that needs to change the default value of fields containing existing data, and with this method it would be fine. Switching to use changeField will likely fall foul of the 'can't change tables with existing data' rule.

Can I also say: impacts on module/theme/etc devs should prevent change records being actioned until the work is complete - not half baked.