Why should the database script in the online upgrade be arranged in version order, and what should be done if it fails halfway

📅 October 12, 2026 👁️ 15

Why should the database scripts in the online upgrade be arranged in version order, because each script defaults to the previous one having been executed: a script adds a new field to the table, and the next one writes values to this field; if the order is reversed, the next one will not find the field and report an error directly; if it continues to run further, it will continue to rewrite the modified structure based on the old assumptions. As for what to do if it fails halfway, the correct treatment is to stop immediately and record the failed position in the log, rather than skipping the error and continuing to execute the remaining scripts - the more scripts that are executed, the greater the distance between the library structure and the program code, and the higher the cost of troubleshooting.

Why can't the order depend on anything other than the filename?

The upgrade script is essentially a time-accumulating dependency chain. Version A renamed the field, Version B built an index based on the new name, and Version C filled in data based on the new index.The program code reads the structure of the latest version, but the scripts are arranged according to their output time. The two can be aligned only by the order of execution. Therefore, placing the same batch of scripts in the same directory and running them in ascending order of version number is the premise for the establishment of this dependency chain.PbootCMS in the update records of V3.2.26 clearly stated this agreement: the upgrade SQL is unified in the script directory and executed in version order. The scripts scattered in the new equipment backup directory are only reserved for use in new installations.Separating the 'new installation' and 'upgrade' scripts is to avoid the installation SQL statements being mixed into the upgrade sequence and executed repeatedly.

What will be left out if you skip intermediate versions?

The most common problem during cross-version upgrade is not error, but the appearance of success. There are three common manifestations: fields are missing but the program reads the default value, the page displays normally, but the statistical data continues to deviate; the index is not built, the function is available but the query becomes slower and slower; old data is not filled back according to the new rules, and the口径 is inconsistent when the old and new content are displayed in the same place. This kind of state is difficult to deduce the cause from the phenomenon, because there is no error. A feasible approach is to let the upgrade program itself refuse to execute out of order: each time only allow continuous running from the current record version number, and stop asking when the version number is missing, rather than guessing from which entry to start.

Why stopping at failure is safer than continuing to run

The fixes for the program 'Tongxing Program V3.2.25' can explain this difference. The previous issue was that when the migration failed, it did not log, did not report errors to specific scripts, and the upgrade continued to the end, with the administrator seeing a successful prompt.The behavior after repair is to log the failure and stop the upgrade, while skipping pure comment fragments. The difference between the two methods lies in where the error remains: stopping at the first failure point, the library structure only progresses to that step, and when rolling back, it only needs to go back to the backup before the failure;If you keep running, the error will be scattered throughout each subsequent script, and by the time an exception is found, it's unclear at what step it began to deviate. Pure comment snippets should not be considered failures, as comments themselves do not change the structure; treating them as errors would stop a potentially normal upgrade, which is the reason it is separately explained in this repair record.

What order to handle after failure

Stage What to do first Judgment basis What actions to take next
Before upgrading Make a complete backup Both data and static files need to be overwritten, a missing item will result in an incomplete site after restoration Note the current version number and script list
Fail at the moment Read the log to locate the script The log should specify which version and line the failure occurred in Do not execute the entire batch script repeatedly
Repair period Handle the failed script separately Confirm whether it is a structural conflict, field already exists, or permission issue Manually complete the version changes, and then continue with the subsequent versions
Restore Return to the backup point The structure cannot be aligned and cannot be repaired in the short term Restore data and static files, and then schedule the next upgrade
Check Verify section by section Check the new field, index, and historical data backfill separately Record the results, keep logs

Check what needs to be verified before and after the upgrade

Before the upgrade, the backup needs to cover both data and static files. If only the database is backed up, the changes in the upload directory and template cannot be restored together. AnQiCMS (AnQi CMS) has made this a backend capability: backup and restore support data and static files, generate a backup in the background first before starting the script. The deployment form also affects the operation method, sites deployed with Baota panel or Docker image can leave an additional snapshot before the upgrade, and container mode is also convenient for rolling back to the previous image version.

The post-upgrade verification is carried out in three steps: check if the new fields and indexes are in place for the structural item; check if the historical content is filled in according to the new rules for the data item; check if the three main paths of list, detail, and form submission are normal for the behavioral item. The failure prompt should have a destination, and in-station support email reminders should be sent in advance to set up notification targets related to the upgrade, which is earlier than finding problems by reviewing logs after the fact. Clean up the temporary script files after verification to avoid being mistakenly treated as a pending item during the next upgrade.

Common questions

Question: Can the upgrade script be renamed to control the execution order?Answer: Renaming only affects file sorting and does not affect the version judgment in the script content. The order should be handed over to the upgrade program to decide according to the recorded version number. Manual renaming is easy to cause the record to be out of sync with the actual executed file.

Question: Can you ignore the error message saying that the field already exists?Answer: First, confirm whether this script has been executed. If it has indeed been executed, it means that the version number record does not match the actual structure, and the record should be corrected to the correct version before continuing; ignoring directly may skip over the truly unexecuted one.

Question: Can you rerun the entire batch of scripts after interruption?Answer: It depends on whether the script can be executed repeatedly. It can be used with the 'create if not exists' judgment, but will report an error if it is retried after directly creating a table or renaming. It is recommended to back up before re-running and judge each item in order from the failed position according to the log.

Related articles

The explicit specification of an index in a list query is actually slower, in what situations will it degrade to a full table scan?

Writing a fixed index hint in a list query is equivalent to letting the optimizer give up the opportunity to choose a path based on statistical information: when the hint points to an index that does not match the current conditions, the query that could have used a covering index or range scan will be pushed to a more costly execution method, and further degraded into a full table scan when the conditions fail. The same program PbootCMS has fixed the issue of list tags degrading to a full table scan due to index hints in the update records of V3.2.26, and has unified the new libraries to be indexed by the title field.

2026-10-12

Why does the program overwrite the entire site configuration file when saving settings, and why does it overwrite the rules I added myself?

When saving settings, the program overwrites the directory-level configuration file, taking away the manually added rules along with it, because these files are only one copy, generated in full by the program according to its own template. The same program PbootCMS has fixed this issue in the update record of V3.2.26: When Apache turns on pseudo-static, it misjudges the environment, causing the configuration file under the site directory to be overwritten every time it is saved. The approach is to separate the rules managed by the program from the rules added by operations and maintain them in two places, backup before modification, and compare item by item after modification.

2026-10-12

What is the situation when the login credentials are partitioned by the top-level site when embedded by other sites?

Login credentials with partition attributes are stored separately by the top-level site: one is read when the same address is accessed directly, and another is read when the page is embedded by other sites, and they do not share. The official document states that this attribute indicates that credentials should be stored using partitioned storage, and it must be set at the same time as the security mark, and it is recommended to bind the credentials to the host with a hostname prefix name instead of a registrable domain. If the site assumes that the login state is globally shared, it will not be read in the embedded scenario.

2026-10-12

In the front-end monitoring, the loading time of cross-domain images is all zero, which response header should be added

The loading time of cross-domain images is read as zero in the front-end monitoring, the missing is the timing pass response header. The official document defines: this header specifies which sources are allowed to see the attribute values obtained through the resource timing interface, otherwise these values will be reported as zero due to cross-domain restrictions. The value can be a wildcard to release all sources, or a comma-separated list of sources. It only affects timing readings and does not change the access permissions of the resources, so adding this header solves the attribution problem, not the access problem.

2026-10-12

Why would the entry be lost and keep getting bigger when writing the intercept list to a file?

Writing the login intercept list to a single file can easily cause loss of entries under concurrent writing: two requests read the same content at the same time, append their own content respectively, and write it back separately, the latter overwriting the former, and the intercepted addresses thus disappear from the list. Files without a capacity limit will continue to grow, and the time to read and parse will become longer; irregular malformed entries can cause parsing errors directly, resulting in the overall failure of the list. The list is just the first layer, and the server still needs to have independent verification and captcha steps.

2026-10-12

The cause of the core announcement is writing the built-in third-party library, in addition to waiting for the patch, the station also needs to look at which part

The cause is written in the core announcement of the built-in third-party library, the vulnerability is not in the code written by the station itself, but it is distributed with the core, so it cannot be avoided by changing your own template or business code, and can only follow the core version. When following up, read three sections: the upper and lower bounds of the affected range determine whether your version is hit, the fixed version determines which version to upgrade to, and the rating and exploitation conditions determine the priority of scheduling. Taking the Drupal announcement SA-CORE-2026-013 as an example, the affected range spans three branches, and the fixes are in the latest version of each branch.

2026-10-12

Under the same repair date, there are two announcements with different reporting dates hanging, and follow-up should be arranged according to which time.

Under the same repair date, there are two announcements with different reporting dates. The follow-up is arranged according to the repair date, not the reporting date. The repair date represents the actual release of the patch with which version, which is the day you can start working; the reporting date only indicates the time the vulnerability was reported, used to estimate how long the exposure window is; the announcement release date is the time the information is released, usually not earlier than the repair date. Taking the two core announcements of Joomla Security Center as an example, the reporting dates are August 19 and August 2, respectively, and the repair dates are both September 25, and the affected range and upgrade target version are also consistent.

2026-10-12

What will happen to the request being transmitted at the moment of configuration reload

The request being transmitted at the moment of configuration reload will not be disconnected directly by default: the master process retains the old working process to continue handling the established connections, and new connections are handed over to the working process started with the new configuration. What will really be disconnected is the exit time limit you set - when the time limit is reached, the process will try to close all connections still open, and large file uploads and long connections may be interrupted accordingly. Setting the time limit too short affects the transmission of requests in progress, and setting it too long will cause the old process to linger and the time for the old and new configurations to coexist to become longer.

2026-10-12