Application database SQL version upgrading method and device, equipment and storage medium

By introducing a dedicated code package for the DM database and using a database historical migration record table into Flyway, the issue of Flyway's lack of support for the DM database was resolved, enabling automated upgrades of the DM database SQL version and improving upgrade efficiency and success rate.

CN121597232APending Publication Date: 2026-03-03BEIJING HONGTENG INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411147191.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-20
Publication Date
2026-03-03

AI Technical Summary

Technical Problem

The existing Flyway framework does not support DM database, which means that upgrading the SQL version of the application database in DM database requires manual operation. This is prone to omissions, duplicate imports, or incorrect import order, resulting in upgrade failure.

Method used

By introducing a dedicated code package for the DM database into Flyway, the connection between Flyway and the DM database is realized. The database historical migration record table is used to automatically manage and record the SQL version upgrade process, avoiding omissions and duplications in manual operations.

Benefits of technology

It improves the efficiency and success rate of upgrading the SQL version of the DM database, ensures the automation and accuracy of the upgrade process, and reduces the risk of manual intervention.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121597232A_ABST
    Figure CN121597232A_ABST
Patent Text Reader

Abstract

The invention discloses an application database SQL version upgrading method and device, equipment and a storage medium. The method comprises the steps of obtaining a database migration instruction based on flyway; in response to the database migration instruction, loading application database SQL files of various versions in the DM database under the condition that the flyway and the DM database are in a connection state; an application database SQL file corresponding to the to-be-migrated application database SQL version in the DM database is executed based on a database historical migration record table, so that upgrading of the application database SQL version in the DM database is completed, and the database historical migration record table is used for recording the execution state of the application database SQL file of each version in the DM database. Therefore, under the condition that flyway supports the DM database, operation and maintenance personnel can automatically manage and record the upgrading and updating condition of the SQL version of the application database in the DM database through the database migration instruction and the database historical migration record table, and the upgrading efficiency of the SQL version of the application database is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, electronic device, and computer storage medium for upgrading SQL versions of an application database. Background Technology

[0002] Flyway is an open-source database version management framework. Through its extended interfaces, new databases can be integrated, enabling version management of those databases using Flyway. DM Database is a high-performance database management system with completely independent intellectual property rights. It provides data storage, querying, and transaction processing functions, and is a concrete implementation of application databases, offering strong support and assurance for various application databases.

[0003] Among related technologies, Flyway only supports MySQL databases and does not support DM databases. Furthermore, during application upgrades, operations personnel often need to manually import and execute the new application database SQL file in the DM database, i.e., manually upgrade the application database SQL version. However, this method not only requires a certain amount of manual labor and time, but is also prone to problems such as repeatedly importing the same SQL file, missing the import of a certain version of the SQL file, or incorrect execution order of the imported SQL files, leading to application database SQL version upgrade failures. Summary of the Invention

[0004] This application provides a method, apparatus, electronic device, and computer storage medium for upgrading application database SQL versions. When it is confirmed that Flyway supports the DM database (i.e., Flyway and DM database are connected), it allows maintenance personnel to automatically manage and record the upgrade and update status of application database SQL versions in the DM database using scripts or command lines (database migration commands) and a database historical migration record table. This avoids omissions and duplications that may occur when maintenance personnel manually update application database SQL versions in the DM database, thus improving the efficiency and success rate of application database SQL version upgrades. The above technical solution is as follows:

[0005] In a first aspect, embodiments of this application provide a method for upgrading an application database SQL version, the method comprising:

[0006] Obtain database migration instructions based on flyway;

[0007] In response to the above database migration command, while the above flyway and the DM database are in a connected state, load the application database SQL files of each version in the above DM database;

[0008] Based on the database historical migration record table, the application database SQL file corresponding to the application database SQL version to be migrated in the above-mentioned Dameng database is executed to complete the upgrade of the application database SQL version in the above-mentioned Dameng database; the above-mentioned database historical migration record table is used to record the execution status of each version of the application database SQL file in the above-mentioned Dameng database.

[0009] In one possible implementation, after receiving the database migration instruction based on Flyway and before loading the application database SQL files of various versions in the DM database, the method further includes:

[0010] In response to the aforementioned database migration instruction, if the database type indicated by the database connection Uniform Resource Locator corresponding to the aforementioned flyway is a DM database, the preset DM code package is invoked to obtain the version number of the DM database corresponding to the preset DM code package; the aforementioned preset DM code package is a DM database-specific code package pre-set in the aforementioned flyway.

[0011] Determine whether the above version number is within the range of connectable version numbers corresponding to the above flyway;

[0012] If so, then establish a connection between Flyway and the DM database based on the aforementioned DM database driver package.

[0013] In one possible implementation, after obtaining the version number of the DM database corresponding to the preset DM code package, and before determining whether the version number is within the range of connectable version numbers corresponding to Flyway, the method further includes:

[0014] If the above version number does not include a minor version number, assign the minor version number corresponding to the above version number to zero to obtain the version number corresponding to the above Dameng database.

[0015] The determination of whether the above version number is within the range of connectable version numbers corresponding to the above Flyway includes:

[0016] Determine whether the version number after the above assignment is within the range of connectable version numbers corresponding to the above flyway.

[0017] In one possible implementation, the above-mentioned method of obtaining database migration instructions based on Flyway includes:

[0018] After the application system version upgrade is completed, the database migration command corresponding to the above application system is triggered based on Flyway;

[0019] After executing the application database SQL file corresponding to the application database SQL version to be migrated in the DM database based on the database historical migration record table to complete the upgrade of the application database SQL version in the DM database, the above method also includes:

[0020] Start the above application system to run the upgraded version of the above application system.

[0021] In one possible implementation, after obtaining the database migration instructions based on Flyway and before loading the application database SQL files for each version in the DM database, the method further includes:

[0022] Based on the preset DM code package corresponding to the above DM database, create the database historical migration record table corresponding to the above DM database.

[0023] With Flyway and the DM database connected, the historical migration record table is used to record the historical execution status of SQL files for each version of the application database in the DM database.

[0024] In one possible implementation, after loading the application database SQL files for each version of the aforementioned DM database, and before executing the application database SQL file corresponding to the application database SQL version to be migrated in the aforementioned DM database based on the database historical migration record table, the method further includes:

[0025] Based on the database historical migration record table, determine the SQL version of the historical application database that is in the executed state in the above-mentioned Dameng database;

[0026] Determine whether the current checksum of the SQL file corresponding to the above historical application database SQL version is consistent with the initial checksum.

[0027] If so, then execute the steps described above, which involve executing the application database SQL file corresponding to the application database SQL version to be migrated in the DM database based on the database historical migration record table.

[0028] In one possible implementation, the above method also includes:

[0029] Based on the above, flyway receives database version query commands;

[0030] In response to the above database version query command, query the latest version information corresponding to the application database SQL file in the above Dameng database.

[0031] Secondly, embodiments of this application provide an application database SQL version upgrade device, the application database SQL version upgrade device comprising:

[0032] The first acquisition module is used to acquire database migration instructions based on flyway;

[0033] The loading module is used to respond to the above database migration instructions and, when the above Flyway and the DM database are in a connected state, load the application database SQL files of each version in the above DM database;

[0034] The execution module is used to execute the application database SQL file corresponding to the application database SQL version to be migrated in the above-mentioned Dameng database based on the database historical migration record table, so as to complete the upgrade of the application database SQL version in the above-mentioned Dameng database; the database historical migration record table is used to record the execution status of each version of the application database SQL file in the above-mentioned Dameng database.

[0035] In one possible implementation, the aforementioned application database SQL version upgrade device further includes:

[0036] The second acquisition module is used to respond to the above database migration instruction. When the database connection Uniform Resource Locator corresponding to the above flyway indicates that the database type of the connection is a DM database, the module calls the preset DM code package to obtain the version number of the DM database corresponding to the preset DM code package. The preset DM code package is a DM database-specific code package that is pre-set in the above flyway.

[0037] The first judgment module is used to determine whether the above version number is within the range of connectable version numbers corresponding to the above flyway;

[0038] The connection module is used to establish a connection between Flyway and the DM database based on the driver package of the DM database if the condition is met.

[0039] In one possible implementation, the aforementioned application database SQL version upgrade device further includes:

[0040] The assignment module is used to assign the minor version number corresponding to the above version number to zero when the above version number does not carry a minor version number, so as to obtain the version number corresponding to the above Dameng database after assignment.

[0041] The first judgment module mentioned above is specifically used for:

[0042] Determine whether the version number after the above assignment is within the range of connectable version numbers corresponding to the above flyway.

[0043] In one possible implementation, the first acquisition module described above is specifically used for:

[0044] After the application system version upgrade is completed, the database migration command corresponding to the above application system is triggered based on Flyway;

[0045] The aforementioned application database SQL version upgrade device also includes:

[0046] The startup module is used to start the aforementioned application system to run the upgraded version of the aforementioned application system.

[0047] In one possible implementation, the aforementioned application database SQL version upgrade device further includes:

[0048] The module is used to create a database history migration record table corresponding to the aforementioned DM database based on the preset DM code package corresponding to the aforementioned DM database.

[0049] The recording module is used to record the historical execution status of the SQL files of each version of the application database in the DM database when the above-mentioned Flyway and DM database are in a connected state.

[0050] In one possible implementation, the aforementioned application database SQL version upgrade device further includes:

[0051] The determination module is used to determine the SQL version of the historical application database that is in the executed state in the above-mentioned Dameng database based on the database historical migration record table;

[0052] The second judgment module is used to determine whether the current check value of the historical application database SQL file corresponding to the above-mentioned historical application database SQL version is consistent with the initial check value.

[0053] The above execution module is specifically used to: if the current verification value is consistent with the initial verification value, then execute the above steps based on the database historical migration record table to execute the application database SQL file corresponding to the application database SQL version to be migrated in the above Dameng database.

[0054] In one possible implementation, the aforementioned application database SQL version upgrade device further includes:

[0055] The receiving module is used to receive database version query commands based on the aforementioned flyway;

[0056] The query module is used to respond to the above database version query command and query the latest version information corresponding to the application database SQL file in the above Dameng database.

[0057] Thirdly, embodiments of this application provide an electronic device, including: a processor and a memory;

[0058] The processor is connected to the memory.

[0059] The aforementioned memory is used to store executable program code;

[0060] The processor reads the executable program code stored in the memory to run the program corresponding to the executable program code, so as to execute the method provided by the first aspect of the embodiments of this specification or any possible implementation of the first aspect.

[0061] Fourthly, embodiments of this specification provide a computer storage medium storing a plurality of instructions adapted for loading by a processor and executing the method provided by the first aspect of the embodiments of this specification or any possible implementation thereof.

[0062] The beneficial effects of the technical solutions provided in some embodiments of this application include at least the following:

[0063] In one or more embodiments of this application, a database migration instruction is obtained based on Flyway; in response to the database migration instruction, when Flyway is connected to the DM database, application database SQL files of various versions in the DM database are loaded; based on the database historical migration record table, the application database SQL file corresponding to the application database SQL version to be migrated in the DM database is executed to complete the upgrade of the application database SQL version in the DM database; the database historical migration record table is used to record the execution status of each version of the application database SQL file in the DM database, thereby allowing maintenance personnel to automatically manage and record the upgrade and update status of the application database SQL version in the DM database through scripts or command lines (database migration instructions) and the database historical migration record table when it is determined that Flyway supports the DM database (i.e., Flyway is connected to the DM database), avoiding omissions and duplications when maintenance personnel manually update the application database SQL version in the DM database, and improving the efficiency and success rate of application database SQL version upgrades.

[0064] The above description is merely an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description

[0065] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0066] Figure 1 This application provides an architectural diagram of an application database SQL version upgrade system.

[0067] Figure 2 A flowchart illustrating an application database SQL version upgrade method provided in this application embodiment;

[0068] Figure 3 A flowchart illustrating another application database SQL version upgrade method provided in this application embodiment;

[0069] Figure 4 A schematic diagram illustrating the implementation process of an application database SQL version query in an embodiment of this application;

[0070] Figure 5 A schematic diagram of the structure of an application database SQL version upgrade device provided in an embodiment of this application;

[0071] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0072] To make the features and advantages of this application more apparent and understandable, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0073] The terms "first," "second," "third," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.

[0074] Please refer to the following. Figure 1This is a schematic diagram of the architecture of an application database SQL version upgrade system provided in an exemplary embodiment of this specification. Figure 1 As shown, the application database SQL version upgrade system includes: operation and maintenance terminal 110 and server 120. Among them:

[0075] The maintenance client 110 can interact with the server 120 via the network to receive messages from or send messages to the server 120. Alternatively, the maintenance client 110 can interact with the server 120 via the network to receive messages or data sent to the server 120 by other users. The maintenance client 120 can be hardware or software. When the maintenance client 120 is hardware, it can be various electronic devices, including but not limited to smartwatches, smartphones, tablets, laptops, and desktop computers. When the maintenance client 110 is software, it can be installed in the electronic devices listed above. It can be implemented as multiple software programs or software modules (e.g., to provide distributed services) or as a single software program or software module; no specific limitation is made here.

[0076] The maintenance terminal 110 may include one or more terminals corresponding to maintenance personnel. These terminals may, but are not limited to, have a small program or application installed that can query and manage the database. Optionally, maintenance personnel may, but are not limited to, log in to the small program or application installed on the maintenance terminal 110 using their own account, mobile phone number, etc., to trigger the maintenance terminal 110 to send a corresponding database version query command to the server 120 storing the DM database corresponding to the application system, in order to query the latest updated version information of the application database SQL file in the DM database based on Flyway.

[0077] Server 120 can be a server that provides upgrades to various application database SQL versions, such as, but not limited to, a server storing multiple applications' corresponding DM databases. It internally installs Flyway, which has been registered with the DM database type, to automatically manage the upgrades of the corresponding application database SQL files in the DM database based on application system upgrades. It should be noted that Server 120 can be hardware or software. When Server 120 is hardware, it can be implemented as a distributed server cluster composed of multiple servers, or as a single server. When Server 120 is software, it can be implemented as multiple software programs or software modules (e.g., used to provide distributed services), or as a single software program or software module; no specific limitations are made here. Server 120 can be, but is not limited to, a hardware server, a virtual server, a cloud server, etc.

[0078] In this embodiment of the specification, after the server 120 obtains the database migration instruction based on Flyway, it can respond to the database migration instruction and, while Flyway and the DM database are connected, load the application database SQL files of various versions in the DM database; execute the application database SQL file corresponding to the application database SQL version to be migrated in the DM database based on the database historical migration record table, so as to complete the upgrade of the application database SQL version in the DM database; the database historical migration record table is used to record the execution status of the application database SQL files of various versions in the DM database.

[0079] Understandably, the application database SQL version upgrade method provided in this application can be executed by the aforementioned server 120 or by the aforementioned operation and maintenance terminal 110, and this application does not limit it in this regard.

[0080] The network can be a medium that provides a communication link between the maintenance terminal 110 and the server 120, or it can be the Internet, which includes network devices and transmission media, and is not limited to these. The transmission media can be a wired link, such as, but not limited to, coaxial cable, fiber optic cable, and digital subscriber line (DSL), or a wireless link, such as, but not limited to, wireless fidelity (WIFI), Hypertext Transfer Protocol (HTTP), Bluetooth, and electronic device networks.

[0081] Understandably, Figure 1 The number of operation and maintenance terminals 110 and servers 120 in the application database SQL version upgrade system shown is only an example. In a specific implementation, the application database SQL version upgrade system can contain any number of operation and maintenance terminals 110 and servers 120.

[0082] The following example illustrates an application database SQL version upgrade method provided by an exemplary embodiment of this application, using the server performing an application database SQL version upgrade. Specifically... Figure 2 As shown, the application database SQL version upgrade method includes the following steps:

[0083] S201, obtain database migration instructions based on Flyway.

[0084] Specifically, Flyway is an open-source database version management framework. Through its extended interfaces, new databases can be accessed, enabling version management of those databases using Flyway. Since Flyway only supports MySQL and not DM databases, developers must first create a dedicated DM database code package (dm, i.e., a pre-defined DM code package) within Flyway and register the DM database type before performing an application database SQL version upgrade. This completes the Flyway adaptation process, ensuring Flyway supports DM databases. The aforementioned database migration commands (e.g., but not limited to Flyway migrate) can be manually triggered by developers or operations personnel using Flyway, or automatically triggered by pre-defined code or script command lines on the server after detecting an upgrade to the application system corresponding to the DM database. This application embodiment does not limit this. Database migration is the migration from one version to another within the same database system; that is, the aforementioned database migration commands can, but are not limited to, instructing the application database SQL text in the DM database to upgrade from an older version to a newer version.

[0085] S202, in response to the database migration command, loads the application database SQL files of various versions in the DM database while Flyway and DM database are connected.

[0086] Specifically, the DM database stores application database SQL files for various versions of the application system (including, but not limited to, older versions already in use and newer versions to be used). When an application system is upgraded, the application database SQL file for the new version corresponding to its upgrade function will be saved in the DM database. After receiving the database migration instruction, it first checks whether Flyway and the DM database are connected. If so, it directly reads the application database SQL files for each version from the DM database.

[0087] Understandably, different versions or functions of the same application system correspond to different versions of the application database SQL files, and different application systems correspond to different DM databases that store the application database SQL files. In other words, a DM database includes all versions of the application database SQL files corresponding to an application system.

[0088] Optionally, in step S201 above, after obtaining the database migration instruction based on Flyway and before loading the application database SQL files of various versions in the DM database, it is also possible, but not limited to, responding to the database migration instruction. If the database connection Uniform Resource Locator (i.e., the JDBC connection URL) corresponding to Flyway indicates that the database type to be connected is a DM database, it means that the database to be connected is a DM database. In this case, a preset DM code package can be called to obtain the version number of the DM database corresponding to the preset DM code package, and it is determined whether the version number is within the range of connectable version numbers corresponding to Flyway. If so, it means that Flyway can normally connect to the DM database corresponding to that version number. Then, based on the aforementioned DM database driver package (e.g., but not limited to the jar package DmJdbcDriver18.jar), a connection between Flyway and the DM database is established to ensure that maintenance personnel can normally connect to and manage the DM database based on Flyway on the server. The aforementioned preset DM code package is a DM database-specific code package pre-defined in Flyway, which can be developed based on, but not limited to, the code framework provided by Flyway and the DM database.

[0089] Furthermore, since Flyway typically uses a major version number and a minor version number when determining the range of connectable version numbers, and the DM database does not have a minor version number, the version number of the DM database obtained by the server through Flyway will not have a minor version number. This can easily lead to Flyway's own program being outside the range of the preset DM code package, resulting in errors or even failure to call the preset DM code package. To solve the above problem, this embodiment, after obtaining the version number of the DM database corresponding to the preset DM code package, will first determine whether the version number carries a minor version number. If the version number does not carry a minor version number, the minor version number corresponding to the version number will be directly assigned to zero, resulting in the assigned version number of the DM database (for example, but not limited to, when the obtained version number is 8, its assigned version number should be 8.0; where 8 is the major version number and 0 is the minor version number). Then, it is determined whether the version number after the above assignment is within the range of connectable version numbers corresponding to Flyway. This avoids problems such as Flyway's own program being out of the range of the preset DM code package due to the version number of the DM database obtained by Flyway not carrying the minor version number, resulting in errors or even failure to call the preset DM code package. This improves the performance of automatically connecting to and managing the DM database based on Flyway.

[0090] Optionally, after Flyway first obtains the database migration instruction for an application database SQL file in a specific DM database, a database history migration record table (e.g., but not limited to the flyway_schema_history table) can be created based on the preset DM code package corresponding to that DM database already established in Flyway. While Flyway is connected to the DM database, the database history migration record table is used to record the historical execution status (i.e., historical migration status) of each version of the application database SQL file in the DM database. This allows developers and operations personnel to intuitively and efficiently understand the upgrade status of each version of the application database SQL file in the DM database and efficiently and accurately manage the upgrade, query, and other operations of each version of the application database SQL file in the DM database.

[0091] Please continue to refer to the following. Figure 2 ,like Figure 2 As shown, in S202 above, in response to the database migration instruction, while Flyway and the DM database are connected, after loading the application database SQL files of various versions in the DM database, the application database SQL version upgrade method further includes:

[0092] S203: Based on the database historical migration record table, execute the application database SQL file corresponding to the application database SQL version to be migrated in the DM database to complete the upgrade of the application database SQL version in the DM database.

[0093] Specifically, the application database SQL version to be migrated refers to the version of the application database SQL file in the DM database that is not currently being executed. The database historical migration record table is used to record the execution status of each version of the application database SQL file in the DM database. That is, after loading all versions of the application database SQL files in the DM database, the application database SQL files in the DM database that are not currently being executed can be identified based on the database historical migration record table. These are the application database SQL files that need to be upgraded. Then, the scripts within these application database SQL files are executed to complete the upgrade of the application database SQL version in the DM database.

[0094] Understandably, when there are multiple application database SQL files in the DM database that are not in an executed state, the scripts of the multiple application database SQL files in the multiple unexecuted states can be executed sequentially according to the record time (save time) of the multiple unexecuted application database SQL files in the database historical migration record table, in order of time, to ensure the successful upgrade of each application database SQL version in the DM database and the normal operation of the corresponding application system after the upgrade.

[0095] Optionally, to avoid issues such as developers modifying the old version of the application database SQL file that has already been upgraded during development, leading to upgrade failures or errors in the new version, before executing the application database SQL file corresponding to the application database SQL version to be migrated in the DM database based on the database historical migration record table, it is possible, but not limited to, first determining the historical application database SQL version (i.e., the old version) that is currently in the execution state in the DM database based on the database historical migration record table, and then determining whether the current checksum (e.g., but not limited to MD5 value or checksum value) of the historical application database SQL file corresponding to the historical application database SQL version is consistent with its initial checksum; if they are consistent, it means that the historical application database SQL file that has already been executed has not been modified, and the above S203 can be executed smoothly, executing the application database SQL file corresponding to the application database SQL version to be migrated in the DM database based on the database historical migration record table, thereby avoiding the problem of errors occurring in the upgrade process of the new version of the application database SQL file due to modifications of the historical application database SQL file that has already been upgraded, improving the success rate and security of the application database SQL version upgrade. If there is a discrepancy, it indicates that the previously executed historical application database SQL file has been modified, and an error will be reported directly, prompting developers or operations personnel that the historical application database SQL file has been modified.

[0096] In this embodiment, a database migration instruction is obtained based on Flyway. In response to the database migration instruction, and while Flyway and the DM database are connected, application database SQL files for each version of the DM database are loaded. Based on the database historical migration record table, the application database SQL file corresponding to the application database SQL version to be migrated in the DM database is executed to complete the upgrade of the application database SQL version in the DM database. The database historical migration record table is used to record the execution status of each version of the application database SQL file in the DM database. Therefore, when it is determined that Flyway supports the DM database (i.e., Flyway and the DM database are connected), maintenance personnel can automatically manage and record the upgrade and update status of the application database SQL version in the DM database through scripts or command lines (database migration instructions) and the database historical migration record table. This avoids omissions and duplications when maintenance personnel manually update the application database SQL version in the DM database, improving the efficiency and success rate of application database SQL version upgrades.

[0097] Please refer to the following. Figure 3 This is a flowchart illustrating another application database SQL version upgrade method provided in an exemplary embodiment of this application. Specifically, as shown... Figure 3 As shown, the application database SQL version upgrade method includes the following steps:

[0098] S301, after the application system version upgrade is completed, the corresponding database migration instruction of the application system is triggered based on Flyway.

[0099] Specifically, after detecting that the application system upgrade in the server has been completed, before the application system is started, the server may, but is not limited to, use a script based on Flyway to automatically trigger the database migration command corresponding to the application system, or have the developer or operations personnel manually trigger the database migration command corresponding to the application system based on Flyway.

[0100] S302, in response to the database migration command, loads the application database SQL files of various versions in the DM database while Flyway and DM database are connected.

[0101] Specifically, S302 is the same as S202, and will not be repeated here.

[0102] S303: Based on the database historical migration record table, execute the application database SQL file corresponding to the application database SQL version to be migrated in the DM database to complete the upgrade of the application database SQL version in the DM database.

[0103] Specifically, S303 is the same as S203, and will not be repeated here.

[0104] S304, Start the application system to run the upgraded version of the application system.

[0105] Specifically, after the application system version upgrade is completed, before starting the application system of this version for the first time, it is necessary to upgrade the application database SQL version in the DM database first to ensure that the version number of the application system is consistent with the corresponding application database SQL version in the DM database. Only then can the application system be started to run the upgraded application system, so that the application system can run normally and use its upgraded functions after startup. This avoids the problem of the application system running errors after startup due to the inconsistency between the version number of the application system and its corresponding application database SQL version, and improves the security and reliability of the application system upgrade.

[0106] Please refer to the following. Figure 4 This is a schematic diagram illustrating the implementation process of an application database SQL version query, provided as an exemplary embodiment of this application. Specifically, as follows... Figure 4 As shown, the implementation process of the application's database SQL version query may include, but is not limited to, the following steps:

[0107] S401 receives database version query commands based on flyway.

[0108] Specifically, when developers or operations personnel want to check the upgrade status of the application database SQL version in the DM database, the server can, but is not limited to, receive database version query commands (such as, but not limited to, flyway info) manually triggered by developers or operations personnel based on flyway.

[0109] S402, in response to the database version query command, queries the latest version information corresponding to the application database SQL file in the Dameng database.

[0110] Specifically, the server can respond to the database version query command to query the latest version information of the application database SQL file in the DM database, that is, to query the latest version number of the application database SQL file that has been upgraded in the DM database.

[0111] Optionally, when developers want to rebuild the application system's development environment, they can, but are not limited to, manually trigger the corresponding database version deletion command based on Flyway to delete the application database SQL files of each version in the DM database.

[0112] Please refer to the following. Figure 5 This is a schematic diagram of the structure of an application database SQL version upgrade device provided in an embodiment of this application. Figure 5 As shown, the application database SQL version upgrade device 500 includes:

[0113] The first acquisition module 510 is used to acquire database migration instructions based on flyway;

[0114] Loading module 520 is used to load the application database SQL files of each version in the above-mentioned DM database in response to the above-mentioned database migration instruction, when the above-mentioned flyway and DM database are in a connected state.

[0115] The execution module 530 is used to execute the application database SQL file corresponding to the application database SQL version to be migrated in the above-mentioned Dameng database based on the database historical migration record table, so as to complete the upgrade of the application database SQL version in the above-mentioned Dameng database; the database historical migration record table is used to record the execution status of each version of the application database SQL file in the above-mentioned Dameng database.

[0116] In one possible implementation, the aforementioned application database SQL version upgrade device 500 further includes:

[0117] The second acquisition module is used to respond to the above database migration instruction. When the database connection Uniform Resource Locator corresponding to the above flyway indicates that the database type of the connection is a DM database, the module calls the preset DM code package to obtain the version number of the DM database corresponding to the preset DM code package. The preset DM code package is a DM database-specific code package that is pre-set in the above flyway.

[0118] The first judgment module is used to determine whether the above version number is within the range of connectable version numbers corresponding to the above flyway;

[0119] The connection module is used to establish a connection between Flyway and the DM database based on the driver package of the DM database if the condition is met.

[0120] In one possible implementation, the aforementioned application database SQL version upgrade device 500 further includes:

[0121] The assignment module is used to assign the minor version number corresponding to the above version number to zero when the above version number does not carry a minor version number, so as to obtain the version number corresponding to the above Dameng database after assignment.

[0122] The first judgment module mentioned above is specifically used for:

[0123] Determine whether the version number after the above assignment is within the range of connectable version numbers corresponding to the above flyway.

[0124] In one possible implementation, the first acquisition module 510 is specifically used for:

[0125] After the application system version upgrade is completed, the database migration command corresponding to the above application system is triggered based on Flyway;

[0126] The aforementioned application database SQL version upgrade device 500 also includes:

[0127] The startup module is used to start the aforementioned application system to run the upgraded version of the aforementioned application system.

[0128] In one possible implementation, the aforementioned application database SQL version upgrade device 500 further includes:

[0129] The module is used to create a database history migration record table corresponding to the aforementioned DM database based on the preset DM code package corresponding to the aforementioned DM database.

[0130] The recording module is used to record the historical execution status of the SQL files of each version of the application database in the DM database when the above-mentioned Flyway and DM database are in a connected state.

[0131] In one possible implementation, the aforementioned application database SQL version upgrade device 500 further includes:

[0132] The determination module is used to determine the SQL version of the historical application database that is in the executed state in the above-mentioned Dameng database based on the database historical migration record table;

[0133] The second judgment module is used to determine whether the current check value of the historical application database SQL file corresponding to the above-mentioned historical application database SQL version is consistent with the initial check value.

[0134] The execution module 530 is specifically used to: if the current verification value is consistent with the initial verification value, execute the steps described above for executing the application database SQL file corresponding to the application database SQL version to be migrated in the DaMeng database based on the database historical migration record table.

[0135] In one possible implementation, the aforementioned application database SQL version upgrade device 500 further includes:

[0136] The receiving module is used to receive database version query commands based on the aforementioned flyway;

[0137] The query module is used to respond to the above database version query command and query the latest version information corresponding to the application database SQL file in the above Dameng database.

[0138] The division of modules in the above-described application database SQL version upgrade device is for illustrative purposes only. In other embodiments, the application database SQL version upgrade device can be divided into different modules as needed to complete all or part of the functions of the above-described application database SQL version upgrade device. The implementation of each module in the application database SQL version upgrade device provided in the embodiments of this specification can be in the form of a computer program. This computer program can run on a terminal or server. The program modules constituted by this computer program can be stored in the memory of the terminal or electronic device. When the computer program is executed by a processor, it implements all or part of the steps of the application database SQL version upgrade method described in the embodiments of this specification.

[0139] Please refer to the following. Figure 6 , Figure 6 This is a schematic diagram of the structure of an electronic device provided as an exemplary embodiment of this specification. For example... Figure 6 As shown, the electronic device 600 may include: at least one processor 610, at least one communication bus 620, user interface 630, at least one network interface 640, and memory 650.

[0140] The communication bus 620 can be used to realize the connection and communication of the above components.

[0141] The user interface 630 may include a display screen and a camera. Optional user interfaces may also include standard wired interfaces and wireless interfaces.

[0142] The network interface 640 may optionally include a Bluetooth module, a Near Field Communication (NFC) module, a Wireless Fidelity (Wi-Fi) module, etc.

[0143] The processor 610 may include one or more processing cores. The processor 610 connects to various parts within the electronic device 600 using various interfaces and lines, and performs various functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in the memory 650, and by calling data stored in the memory 650. Optionally, the processor 610 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 610 may integrate one or a combination of several of the following: a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), and a modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content required for display; and the modem handles wireless communication. It is understood that the modem may also be implemented as a separate chip without being integrated into the processor 610.

[0144] The memory 650 may include random access memory (RAM) or read-only memory (ROM). Optionally, the memory 650 may include a non-transitory computer-readable medium. The memory 650 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 650 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as fetching functions, application database SQL version upgrade functions, execution functions, etc.), instructions for implementing the various method embodiments described above, etc.; the data storage area may store data involved in the various method embodiments described above, etc. Optionally, the memory 650 may also be at least one storage device located remotely from the aforementioned processor 610. Figure 6 As shown, the memory 650, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and program instructions.

[0145] Specifically, the aforementioned electronic device 600 is equipped with a browser, which has a built-in large model; the processor 610 can be used to call program instructions stored in the memory 650 and specifically perform the following operations:

[0146] Based on Flyway, database migration instructions are obtained; in response to the database migration instructions, while Flyway and DM database are connected, application database SQL files of various versions in DM database are loaded; based on the database historical migration record table, the application database SQL file corresponding to the application database SQL version to be migrated in DM database is executed to complete the upgrade of the application database SQL version in DM database; the database historical migration record table is used to record the execution status of application database SQL files of various versions in DM database.

[0147] In some possible embodiments, after receiving the database migration instruction based on Flyway and before loading the application database SQL files of various versions in the DM database, the processor 610 is also used to execute:

[0148] In response to the aforementioned database migration instruction, if the database type indicated by the database connection Uniform Resource Locator corresponding to the aforementioned Flyway is a DM database, a preset DM code package is invoked to obtain the version number of the DM database corresponding to the preset DM code package; the preset DM code package is a DM database-specific code package pre-defined in the aforementioned Flyway; it is determined whether the version number is within the range of connectable version numbers corresponding to the aforementioned Flyway; if so, a connection between the aforementioned Flyway and the aforementioned DM database is established based on the aforementioned DM database driver package.

[0149] In some possible embodiments, after the processor 610 executes the above-mentioned method of obtaining the version number of the DM database corresponding to the preset DM code package, and before the above-mentioned method of determining whether the version number is within the range of connectable version numbers corresponding to the Flyway, it is further configured to execute:

[0150] If the version number does not include a minor version number, assign the minor version number corresponding to the above version number to zero to obtain the version number corresponding to the above-mentioned Dameng database.

[0151] When the processor 610 executes the above-mentioned determination of whether the version number is within the range of connectable version numbers corresponding to the Flyway, it specifically performs the following:

[0152] Determine whether the version number after the above assignment is within the range of connectable version numbers corresponding to the above flyway.

[0153] In some possible embodiments, when the processor 610 executes the database migration instructions obtained based on Flyway, it specifically performs the following:

[0154] After the application system version upgrade is completed, the database migration command corresponding to the above application system is triggered based on Flyway.

[0155] After the processor 610 executes the application database SQL file corresponding to the application database SQL version to be migrated in the DM database based on the database historical migration record table to complete the upgrade of the application database SQL version in the DM database, it is also used to execute:

[0156] Start the above application system to run the upgraded version of the above application system.

[0157] In some possible embodiments, after the processor 610 executes the database migration instructions obtained based on Flyway, and before loading the application database SQL files of various versions in the DM database, it is also used to execute:

[0158] Based on the preset DM code package corresponding to the aforementioned DM database, a database history migration record table corresponding to the aforementioned DM database is created; when the aforementioned Flyway is connected to the DM database, the aforementioned database history migration record table is used to record the historical execution status of the application database SQL files of each version in the aforementioned DM database.

[0159] In some possible embodiments, after the processor 610 executes the above-mentioned loading of application database SQL files of various versions in the DM database, and before the above-mentioned execution of the application database SQL file corresponding to the application database SQL version to be migrated in the DM database based on the database historical migration record table, it is further configured to execute:

[0160] Based on the database historical migration record table, determine the historical application database SQL version that is in the executed state in the above-mentioned Dameng database; determine whether the current check value of the historical application database SQL file corresponding to the above-mentioned historical application database SQL version is consistent with the initial check value; if so, execute the above-mentioned step of executing the application database SQL file corresponding to the application database SQL version to be migrated in the above-mentioned Dameng database based on the database historical migration record table.

[0161] In some possible embodiments, the processor 610 described above is also used to perform:

[0162] Based on the above, flyway receives the database version query command; in response to the above database version query command, it queries the latest version information corresponding to the application database SQL file in the above Dameng database.

[0163] This application also provides a computer storage medium storing instructions that, when executed on a computer or processor, cause the computer or processor to perform one or more steps of any of the above methods. If the constituent modules of the above-described application database SQL version upgrade device are implemented as software functional units and sold or used as independent products, they can be stored in the aforementioned storage medium.

[0164] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in or transmitted through a computer-readable storage medium. The computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).

[0165] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. The aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks. Unless otherwise specified, the technical features of this embodiment and its implementation can be combined arbitrarily.

[0166] The above-described embodiments are merely preferred embodiments of this application and are not intended to limit the scope of this application. Any modifications and improvements made by those skilled in the art to the technical solutions of this application without departing from the spirit of this application should fall within the protection scope defined by the claims of this application.

Claims

1. A method for upgrading an application database SQL version, characterized in that, The method includes: Obtain database migration instructions based on flyway; In response to the database migration instruction, while the flyway is connected to the DM database, the application database SQL files of each version in the DM database are loaded. The application database SQL file corresponding to the application database SQL version to be migrated in the DM database is executed based on the database historical migration record table to complete the upgrade of the application database SQL version in the DM database; the database historical migration record table is used to record the execution status of each version of the application database SQL file in the DM database.

2. The method according to claim 1, characterized in that, After receiving the database migration instruction based on Flyway and before loading the application database SQL files of each version in the DM database, the method further includes: In response to the database migration instruction, if the database type connected by the database connection Uniform Resource Locator corresponding to the flyway is a DM database, a preset DM code package is invoked to obtain the version number of the DM database corresponding to the preset DM code package; the preset DM code package is a DM database-specific code package pre-set in the flyway. Determine whether the version number is within the range of connectable version numbers corresponding to the Flyway; If so, a connection is established between Flyway and the DM database based on the driver package of the DM database.

3. The method according to claim 2, characterized in that, After obtaining the version number of the DM database corresponding to the preset DM code package, and before determining whether the version number is within the range of connectable version numbers corresponding to Flyway, the method further includes: If the version number does not carry a minor version number, the minor version number corresponding to the version number is assigned to zero to obtain the version number of the DM database after the assignment. The step of determining whether the version number is within the range of connectable version numbers corresponding to the Flyway includes: Determine whether the assigned version number is within the range of connectable version numbers corresponding to the flyway.

4. The method according to claim 1, characterized in that, The process of obtaining database migration instructions based on Flyway includes: After the application system version upgrade is completed, the database migration command corresponding to the application system is triggered based on Flyway; After executing the application database SQL file corresponding to the application database SQL version to be migrated in the DM database based on the database historical migration record table to complete the upgrade of the application database SQL version in the DM database, the method further includes: Start the application system to run the upgraded version of the application system.

5. The method according to claim 1, characterized in that, After obtaining the database migration instructions based on Flyway and before loading the application database SQL files of various versions in the DM database, the method further includes: Based on the preset DM code package corresponding to the DM database, create a database history migration record table corresponding to the DM database; When Flyway is connected to the DM database, the historical migration record table of the database is used to record the historical execution status of the SQL files of each version of the application database in the DM database.

6. The method according to claim 1, characterized in that, After loading the application database SQL files of each version in the DM database, and before executing the application database SQL file corresponding to the application database SQL version to be migrated in the DM database based on the database historical migration record table, the method further includes: The SQL version of the historical application database in the DM database that is in the executed state is determined based on the database historical migration record table; Determine whether the current check value of the historical application database SQL file corresponding to the historical application database SQL version is consistent with the initial check value; If so, then execute the step of executing the application database SQL file corresponding to the application database SQL version to be migrated in the DM database based on the database historical migration record table.

7. The method according to claim 1, characterized in that, The method further includes: Based on the flyway, a database version query command is received; In response to the database version query command, query the latest version information corresponding to the application database SQL file in the Dameng database.

8. An application database SQL version upgrade device, characterized in that, The application database SQL version upgrade device includes: The first acquisition module is used to acquire database migration instructions based on flyway; The loading module is used to load the application database SQL files of each version in the DM database in response to the database migration instruction, when the Flyway and the DM database are in a connected state. The execution module is used to execute the application database SQL file corresponding to the application database SQL version to be migrated in the DM database based on the database historical migration record table, so as to complete the upgrade of the application database SQL version in the DM database; the database historical migration record table is used to record the execution status of each version of the application database SQL file in the DM database.

9. An electronic device, characterized in that, include: Processor and memory; among which, The processor is connected to the memory; the memory is used to store executable program code; The processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, in order to perform the method steps as claimed in any one of claims 1-7.

10. A computer storage medium, characterized in that, The computer storage medium stores a plurality of instructions adapted for loading by a processor and executing the method steps as claimed in any one of claims 1-7.