Answer the question
In order to leave comments, you need to log in
Is there an analogue of the dbDelta function from Wordpress in Drupal 7?
The dbDelta function checks the existing structure of the tables in the database, compares it with the structure required by the plugin and, if necessary, makes changes to the tables.
Answer the question
In order to leave comments, you need to log in
Table schema changes are explicitly specified in update hooks .
For example, to increase the size of a varchar field, you need to do something like this ( source ):
/**
* Enlarge URL field size for popular content database table.
*/
function yandex_metrics_reports_update_7202() {
db_drop_unique_key('yandex_metrics_reports_popular_content', 'url');
db_change_field('yandex_metrics_reports_popular_content', 'url', 'url', array(
'description' => 'The url obtained from Yandex.Metrika.',
'type' => 'varchar',
'length' => 2048,
'not null' => TRUE,
'default' => ''
),
array(
'indexes' => array('url' => array(array('url', 255))),
)
);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question