简体   繁体   English

如何在更新模块之前检查是否需要更新数据库

[英]How can I check if database update is required before update module

Is there any good way for it?有什么好的办法吗? Like check some specific code in module.就像检查模块中的一些特定代码一样。

Yes, it's possible.是的,这是可能的。

Let's have an example with webform module.让我们举一个webform模块的例子。

Inside of each module there is an install file.每个模块内部都有一个安装文件。 Open it and scroll to the down, find the last hook.打开它并向下滚动,找到最后一个钩子。 In our example it's:在我们的例子中是:

webform_update_7430 webform_update_7430

Here is a screen (bottom part) of install file.这是安装文件的屏幕(底部)。

在此处输入图片说明

How to check if it is going to run or already processed?如何检查它是要运行还是已经处理?

In order to do that, you need to check system table in your drupal database.为此,您需要检查 drupal 数据库中的系统表。 Find the webform module in system table and check value in schema version column.在系统表中找到 webform 模块并检查模式版本列中的值。 That will be the number of last hook which was run for this module, if in your install file hooks have higher number it means they will be executed during update.这将是为此模块运行的最后一个钩子的编号,如果在您的安装文件中钩子的编号更高,则意味着它们将在更新期间执行。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM