Database business system upgrade management method, device, equipment and medium
By creating the TABLE_VERSION table and the upgrade file included in the new version number in the database, the complex upgrade problem of database table structure is solved, and one-time upgrade across multiple versions is achieved, which simplifies the upgrade process and improves the maintainability of the system.
Patent Information
- Application Number
- CN202411884337.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-04-18
AI Technical Summary
When upgrading the existing database business system, the database table structure is upgraded in complex ways, resulting in a large burden on development, testing and maintenance, the system is not easy to maintain, and the experience is poor.
Create a fixed TABLE_VERSION table in the database to store the version number of the current database structure, and add a new upgrade file for each program version upgrade. The file name contains the current and target version numbers. The corresponding upgrade file will be automatically executed during upgrade.
It realizes one-time upgrade across multiple versions, simplifies the upgrade process of database table structure, reduces the additional burden caused by version iteration, and improves the system's maintainability and response speed.
Smart Images

Figure CN119847560A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of database management, and in particular to a database business system upgrade management method, device, equipment and medium. Background Art
[0002] In the modern information technology environment, there are a large number of database-intensive business systems. The business procedures and database structures of database-intensive business systems are closely related. As a business-oriented application system, with the changes in business and the advancement of technology, its functional requirements have also evolved, prompting it to be frequently iterated and upgraded to meet new requirements. Each version update not only involves adjustments to the front-end user interface and back-end business logic, but may also involve changes to the database table structure.
[0003] When upgrading an existing system, executable programs and libraries can be completely replaced, but the upgrade of the database table structure must be carried out step by step, that is, from one version to the next. For example, if the system is to be upgraded from V1.0 to V4.0, it must first be upgraded from V1.0 to V2.0, then from V2.0 to V3.0, and finally complete the transition from V3.0 to V4.0. Although this method ensures stability and data consistency during the upgrade process, it also brings burdens to the development, testing, and later management and maintenance of the application system, consumes a lot of manpower and material resources, makes the system difficult to maintain, and has a poor experience. Summary of the invention
[0004] The present invention provides a database business system upgrade management method, device, equipment and medium, which solves the problem of complex database table structure upgrade in related technologies.
[0005] In order to achieve the above objectives, this application adopts the following technical solutions:
[0006] In a first aspect, a database business system upgrade management method is provided, comprising:
[0007] Create a fixed TABLE_VERSION table in the database, wherein the TABLE_VERSION table includes a table field V_NUMBER for storing the version number of the current database structure; wherein the initial value of the table field V_NUMBER is set to 1, and is incremented by 1 each time an upgrade is successfully completed;
[0008] For each program version upgrade, if the database structure changes, an upgrade file for upgrading the database is added to the TABLE_VERSION table, and the name of the upgrade file includes: the version number of the current version and the next version to be upgraded; wherein the last line of the upgrade file is the table field V_NUMBER after the current version in the TABLE_VERSION table is updated;
[0009] Database upgrade: query the TABLE_VERSION table before upgrading, and obtain the current version number recorded in the database according to the table field V_NUMBER therein; traverse the names of all the upgrade files, check whether there is an upgrade file of the next version of the current version number, and if so, execute the upgrade file; until the corresponding upgrade file is not found, the upgrade is completed; if the execution of the upgrade file fails, the upgrade fails;
[0010] If the database upgrade fails, the TABLE_VERSION table is queried, the current database version number is obtained according to the table field V_NUMBER therein, and a rollback operation is performed.
[0011] In a first possible implementation manner of the first aspect, the upgrade file is a .sql file.
[0012] In a second aspect, a database service system upgrade management device is provided, comprising:
[0013] A version table creation module is used to create a fixed TABLE_VERSION table in the database, wherein the TABLE_VERSION table includes a table field V_NUMBER for storing the version number of the current database structure; wherein the initial value of the table field V_NUMBER is set to 1, and is incremented by 1 each time an upgrade is successfully completed;
[0014] An upgrade file creation module is used to: for each program version upgrade, if the database structure changes, add an upgrade file for upgrading the database in the TABLE_VERSION table, the name of the upgrade file includes: the version number of the current version and the next version to be upgraded; wherein the last line of the upgrade file is the table field V_NUMBER after the current version is updated in the TABLE_VERSION table;
[0015] The database upgrade module is used to query the TABLE_VERSION table before upgrading, and obtain the current version number recorded in the database according to the table field V_NUMBER therein; traverse the names of all the upgrade files, check whether there is an upgrade file of the next version of the current version number, and if so, execute the upgrade file; until the corresponding upgrade file is not found, the upgrade is completed; if the execution of the upgrade file fails, the upgrade fails;
[0016] The rollback module is used to: if the database upgrade fails, query the TABLE_VERSION table, obtain the current database version number according to the table field V_NUMBER therein, and perform a rollback operation.
[0017] In a first possible implementation manner of the second aspect, the upgrade file is a .sql file.
[0018] In a third aspect, an electronic device is provided, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the database business system upgrade management method as described in the first aspect.
[0019] In a fourth aspect, a readable storage medium is provided, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the database business system upgrade management method described in the first aspect are implemented.
[0020] The database business system upgrade management method of the present invention has the following advantages:
[0021] It realizes one-time upgrade across multiple versions, simplifies the upgrade process of database table structure, thereby reducing the extra burden caused by version iteration and improving the maintainability and responsiveness of the system; at the same time, it can also quickly locate and confirm the actual version status of the database on this basis, providing a version management solution that can effectively improve the flexibility and reliability of database-intensive business systems and meet the ever-changing market needs.
[0022] The device, electronic device and readable storage medium corresponding to the database business system upgrade management method of the present invention can achieve the same technical effect. To avoid repetition, they will not be described here. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 A schematic flow chart of a database business system upgrade management method provided in an embodiment of the present application;
[0024] Figure 2 A schematic diagram of an upgrade file provided in an embodiment of the present application;
[0025] Figure 3 A schematic flowchart of a database upgrade provided in an embodiment of the present application;
[0026] Figure 4 A diagram comparing the upgrade execution process of the present application with that of related technologies provided in an embodiment of the present application;
[0027] Figure 5 A schematic diagram of the structure of a database business system upgrade management device provided in an embodiment of the present application;
[0028] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0029] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined purpose, the technical solutions in the embodiments of the present application are clearly described. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field belong to the scope of protection of the present application.
[0030] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the terms used in this way are interchangeable where appropriate, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0031] The description of the method flow in the specification of the present application and the steps of the flowchart in the drawings of the present specification do not have to be strictly executed according to the step numbers, and the method steps can be executed in a different order. Moreover, some steps can be omitted, multiple steps can be combined into one step, and / or one step can be decomposed into multiple steps.
[0032] The following is a detailed description of the database business system upgrade management method, device, equipment and medium provided in the embodiments of the present application in conjunction with the accompanying drawings and preferred embodiments.
[0033] First, the application scenario of the database business system upgrade management method of the embodiment of the present application is described in detail.
[0034] In the related art, the database table structure upgrade method often needs to be carried out step by step in a predetermined order. For example, upgrading from V1.0 to V4.0 requires three upgrades in the order of V1.0V2.0V3.0V4.0. This method has the following defects or shortcomings in the application process:
[0035] First, it increases the workload of development, testing, and maintenance. Second, the process of upgrading versions one by one is complicated and time-consuming, which can easily lead to extended system downtime and affect user experience. Third, this method is particularly inconvenient when facing large-scale deployment or emergency repair scenarios. In addition, in some situations, when an upgrade fails, it is impossible to determine the specific version of the current database, resulting in data unusable and difficult recovery operations.
[0036] In order to solve the above problems of complex database table structure upgrade and version determination, this application proposes a database business system upgrade management method. This method aims to simplify the upgrade process of the database table structure and support one-time upgrade across multiple versions, thereby reducing the additional burden caused by version iteration and improving the maintainability and response speed of the system; at the same time, this application also provides a version management solution on this basis to ensure that the actual version status of the database can be quickly located and confirmed in any case, providing a solid guarantee for possible problems.
[0037] See also Figure 1 , the present application embodiment provides a database business system upgrade management method, such as Figure 1 As shown, the database service system upgrade management method of the embodiment of the present application includes:
[0038] Step S1, create a fixed TABLE_VERSION table in the database, the TABLE_VERSION table includes a table field V_NUMBER, which is used to store the version number of the current database structure (expressed as an integer); wherein the initial value of the table field V_NUMBER is set to 1, and is incremented by 1 each time an upgrade is successfully completed.
[0039] Step S2, for each program version upgrade, if the database structure changes, a new upgrade file for upgrading the database is added to the TABLE_VERSION table. The name of the upgrade file includes: the version number of the current version and the next version to be upgraded; wherein the last line of the upgrade file is the table field V_NUMBER after the current version in the TABLE_VERSION table is updated.
[0040] For example, see Figure 2In this step, for each program version upgrade, if the database structure changes (addition or modification of tables, triggers, stored procedures, etc.), a new sql file for upgrading the database is added, upgrading from the previous database version n to n+1. The upgrade script file is similar to update_1_to_2.sql. The last line of the upgrade file will update the current version number V_NUMBER in the database: update TABLE_VERSIONT SET V_NUMBER='n+1'.
[0041] Step S3, database upgrade:
[0042] Step S301, query the TABLE_VERSION table before upgrading, and obtain the current version number recorded in the database according to the table field V_NUMBER therein;
[0043] Step S302, traverse the names of all upgrade files, check whether there is an upgrade file of the next version of the current version number, and if so, execute the upgrade file.
[0044] Step S303, repeat step S302 until the corresponding upgrade file is not found, and the upgrade is completed.
[0045] Step S304: If the execution of the upgrade file fails, the upgrade fails.
[0046] For example, see Figure 3 In the above database upgrade process, first query the version number V_NUMBER recorded in the current database, such as N. Check whether there is an upgrade file from N to N+1. If so, execute the upgrade file. After successful execution, the current version of the database becomes N+1. Then search for the upgrade file from N+1 to N+2, and repeat the above process until the corresponding upgrade file is not found, indicating that the upgrade is complete.
[0047] In the specific implementation process, upgrading the business program from version 1 to version N only requires one database structure upgrade operation, and the business program automatically determines and executes the required database structure upgrade script, which greatly simplifies the upgrade process, reduces the error rate, and improves efficiency. Specifically:
[0048] See also Figure 4In the related art, upgrading a business program from version 1 to version N may require up to N database structure upgrade operations. The business program itself performs one upgrade from version 1 to version N; if the business program has structural changes in the corresponding database structure between version 1 and version N, such as version 1 to version 2, version 2 to version 3, version 3 to version 4, and version n-1 to version n, then it is necessary to manually perform N-1 database structure upgrades separately. Therefore, the total number of executions = N-1+1=N times. In the same case, this application adopts the method of database structure upgrade script. The business program only needs to be executed once from version 1 to version N, and the business program will judge and execute the database structure upgrade script by itself.
[0049] Step S4: If the database upgrade fails, query the TABLE_VERSION table, obtain the current database version number according to the table field V_NUMBER therein, and perform a rollback operation.
[0050] The database business system upgrade management method of the present application has the following beneficial effects and advantages:
[0051] The database structure upgrade files that need to be executed manually and independently in sequence are upgraded together with the business program by adding a new script. The corresponding version is automatically executed during the upgrade process. From the perspective of the upgrade personnel, it is not noticeable whether the database structure upgrade is executed during the business program upgrade process. This reduces manual participation, improves execution efficiency, reduces the technical barriers between R&D personnel and engineering implementation personnel, and avoids the problem of database failure due to improper database version control during the upgrade process. It has been verified that the number of manual executions can be reduced by N-1 times, where N is the final version number.
[0052] The database structure automatic upgrade script of this application supports on-demand expansion and on-demand upgrade of different database types. You only need to add the upgrade script of the corresponding database type. Therefore, it has a wide range of applications and strong compatibility. It can be used for international mainstream databases such as MySQL, DAMO, Renmin University of China Jincang, Shentong, and mainstream domestic databases, with strong compatibility and scalability.
[0053] The management of database versions is simple. By judging scripts such as update_1_to_2.sql, it is convenient to confirm the latest version of the current database. If the business program upgrade fails, the latest version of the database can be quickly located by the script name, without affecting the database structure upgrade.
[0054] Based on this, the database business system upgrade management method of the present application realizes a one-time upgrade across multiple versions, simplifies the upgrade process of the database table structure, thereby reducing the additional burden caused by version iteration, and improving the maintainability and response speed of the system; at the same time, on this basis, it can also quickly locate and confirm the actual version status of the database, and provide a version management solution that can effectively improve the flexibility and reliability of database-intensive business systems and meet the ever-changing market needs.
[0055] See also Figure 5 , corresponding to the above-mentioned database business system upgrade management method embodiment, the present application embodiment provides a database business system upgrade management device, the device comprising:
[0056] The version table creation module 1001 is used to create a fixed TABLE_VERSION table in the database, wherein the TABLE_VERSION table includes a table field V_NUMBER for storing the version number of the current database structure; wherein the initial value of the table field V_NUMBER is set to 1, and is incremented by 1 each time an upgrade is successfully completed;
[0057] The upgrade file creation module 1002 is used to: for each program version upgrade, if the database structure changes, add an upgrade file for upgrading the database in the TABLE_VERSION table, the name of the upgrade file includes: the version number of the current version and the next version to be upgraded; wherein the last line of the upgrade file is the table field V_NUMBER after the current version in the TABLE_VERSION table is updated;
[0058] The database upgrade module 1003 is used to query the TABLE_VERSION table before upgrading, and obtain the current version number recorded in the database according to the table field V_NUMBER therein; traverse the names of all the upgrade files, check whether there is an upgrade file of the next version of the current version number, and if so, execute the upgrade file; until the corresponding upgrade file is not found, the upgrade is completed; if the execution of the upgrade file fails, the upgrade fails;
[0059] The rollback module 1004 is used to: if the database upgrade fails, query the TABLE_VERSION table, obtain the current database version number according to the table field V_NUMBER therein, and perform a rollback operation.
[0060] Furthermore, the upgrade file is a .sql file.
[0061] The above-mentioned database business system upgrade management device implements the steps and various processes of the above-mentioned database business system upgrade management method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0062] See also Figure 6 Corresponding to the above-mentioned database business system upgrade management method embodiment, the embodiment of the present application provides an electronic device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the steps of the above-mentioned database business system upgrade management method embodiment and the various processes of the embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0063] The memory 1009 can be used to store software programs and various data. The memory 1009 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 1009 may include a volatile memory or a non-volatile memory, or the memory 1009 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 1009 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
[0064] The processor 1010 may include one or more processing units; optionally, the processor 1010 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 1010.
[0065] Corresponding to the above-mentioned database business system upgrade management method embodiment, the embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by the processor, the steps of the above-mentioned database business system upgrade management method embodiment and the various processes of the embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0066] The processor is the processor in the electronic device described in the above embodiment of the present application. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0067] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0068] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0069] It can be understood that the embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific embodiments, which are merely illustrative and not restrictive, and those skilled in the art are aware that various changes or equivalent replacements can be made to these features and embodiments without departing from the spirit and scope of the present invention. In addition, those of ordinary skill in the art can modify these features and embodiments to adapt to specific circumstances and materials without departing from the spirit and scope of the present invention under the inspiration or teaching of the present application. Therefore, the present invention is not limited by the specific embodiments disclosed herein, and all embodiments falling within the scope of the claims of the present application belong to the scope protected by the present invention.
Claims
1. A database business system upgrade management method, characterized in that: include: Create a fixed TABLE_VERSION table in the database, wherein the TABLE_VERSION table includes a table field V_NUMBER for storing the version number of the current database structure; wherein the initial value of the table field V_NUMBER is set to 1, and is incremented by 1 each time an upgrade is successfully completed; For each program version upgrade, if the database structure changes, an upgrade file for upgrading the database is added to the TABLE_VERSION table, and the name of the upgrade file includes: the version number of the current version and the next version to be upgraded; wherein the last line of the upgrade file is the table field V_NUMBER after the current version in the TABLE_VERSION table is updated; Database upgrade: query the TABLE_VERSION table before upgrading, and obtain the current version number recorded in the database according to the table field V_NUMBER therein; traverse the names of all the upgrade files, check whether there is an upgrade file of the next version of the current version number, and if so, execute the upgrade file; until the corresponding upgrade file is not found, the upgrade is completed; if the execution of the upgrade file fails, the upgrade fails; If the database upgrade fails, the TABLE_VERSION table is queried, the current database version number is obtained according to the table field V_NUMBER therein, and a rollback operation is performed.
2. The database service system upgrade management method according to claim 1, characterized in that: The upgrade file is a .sql file.
3. A database business system upgrade management device, characterized in that: include: A version table creation module is used to create a fixed TABLE_VERSION table in the database, wherein the TABLE_VERSION table includes a table field V_NUMBER for storing the version number of the current database structure; wherein the initial value of the table field V_NUMBER is set to 1, and is incremented by 1 each time an upgrade is successfully completed; An upgrade file creation module is used to: for each program version upgrade, if the database structure changes, add an upgrade file for upgrading the database in the TABLE_VERSION table, the name of the upgrade file includes: the version number of the current version and the next version to be upgraded; wherein the last line of the upgrade file is the table field V_NUMBER after the current version is updated in the TABLE_VERSION table; The database upgrade module is used to query the TABLE_VERSION table before upgrading, and obtain the current version number recorded in the database according to the table field V_NUMBER therein; traverse the names of all the upgrade files, check whether there is an upgrade file of the next version of the current version number, and if so, execute the upgrade file; until the corresponding upgrade file is not found, the upgrade is completed; if the execution of the upgrade file fails, the upgrade fails; The rollback module is used to: if the database upgrade fails, query the TABLE_VERSION table, obtain the current database version number according to the table field V_NUMBER therein, and perform a rollback operation.
4. The database service system upgrade management device according to claim 1, characterized in that: The upgrade file is a .sql file.
5. An electronic device, characterized in that: The electronic device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the steps of the database business system upgrade management method as described in any one of claims 1-2 are implemented.
6. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by the processor, the steps of the database business system upgrade management method as described in any one of claims 1-2 are implemented.
Citation Information
Patent Citations
Database version management method and system
CN112100194A
Method for upgrading network management system in mobile communication
CN1713154A
Cited By
Multi-database automatic upgrading method for multi-service system
CN121833669A
A multi-database automatic upgrading method of a multi-service system
CN121833669B