开发者

Drupal: Proper way to drop a table for module update

开发者 https://www.devze.com 2023-02-19 15:46 出处:网络
What is the proper way to drop a table using hook_update_N? I can\'t find docs on this. If I run update_sql($sql); 开发者_Go百科in my hook--the sql being a drop statement--it reports a failure, even t

What is the proper way to drop a table using hook_update_N? I can't find docs on this. If I run update_sql($sql); 开发者_Go百科in my hook--the sql being a drop statement--it reports a failure, even though checking the db, I can see that the table was dropped.


You should be able to use db_drop_table() (or the Drupal 6 version here).


You can do it in hook_update_N

/**
 * Drop 'my_table' table.
 */
function MYMODULE_update_7001() {
  if (db_table_exists('my_table')) {
    db_drop_table('my_table');
  }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消