Method, device and electronic device for generating upgrade scripts for multi-version databases
By building an upgrade script template, and generating an upgrade script based on maintenance records and version upgrade requests, the problems of repeated work and low maintenance efficiency in multi-version database systems are solved, and automated and efficient version upgrades are achieved.
Patent Information
- Application Number
- CN202110968372.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-23
- Publication Date
- 2025-08-29
- Estimated Expiration
- 2041-08-23
AI Technical Summary
The existing technology has a lot of repetitive work in the upgrade of multi-version database systems, and it is impossible to flexibly select the version to upgrade, and the maintenance efficiency is inefficient.
By pre-built the upgrade script template, the corresponding upgrade script is generated based on maintenance records and version upgrade requests, and automatically filter and sort to achieve free selection of version upgrades.
It reduces the need for manual comparison of database information, improves database upgrade efficiency, and realizes flexible version upgrade and automated script generation.
Smart Images

Figure CN113901021B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of databases, and in particular to a method, device, and electronic device for generating upgrade scripts for multi-version databases. Background Art
[0002] After the database system is put into operation, changes in business will lead to multiple versions of the system in the same period. At the same time, the same system will be deployed in different database systems. When the database structure changes during the system upgrade, the existing solution is to generate upgrade scripts through manual maintenance or simple SQL comparison. If there are many versions involved, the existing solution will inevitably bring a lot of similar repetitive work, and the version upgrade is solidified. Generally, it can only be upgraded from the lower version order, and the version upgrade cannot be freely selected. For example, when the system has versions V1.0, V2.0, V3.0, V4.0, and V5.0, if you want to freely select the version upgrade, you need to maintain the upgrade scripts between the current version and the required upgrade version. In addition, if the same system involves multiple databases, you also need to maintain the upgrade scripts for different databases, resulting in low efficiency in system upgrade and maintenance. Summary of the Invention
[0003] The embodiment of the present application proposes an upgrade script generation method for a multi-version database. By screening the upgrade script corresponding to the version upgrade request from a pre-built upgrade script template, the defect of manually comparing database information in the existing database upgrade process is reduced, and the database upgrade efficiency is improved.
[0004] Specifically, according to the first aspect of the embodiments of the present disclosure, the upgrade script generation method for a multi-version database proposed in the embodiments of the present application includes:
[0005] Obtain maintenance records for multi-version databases, parse the maintenance records to obtain modification information for different versions of the database;
[0006] Build upgrade script templates corresponding to different databases based on the modification information;
[0007] Obtain the version upgrade request for the target database issued by the user, parse the version upgrade request to obtain the target database type and upgrade version range;
[0008] An upgrade script template corresponding to the target database type is selected from the constructed upgrade script templates, and the upgrade script templates are filtered and sorted based on the obtained upgrade version range to obtain an upgrade script corresponding to the version upgrade request.
[0009] Optionally, obtaining maintenance records for a multi-version database and parsing the maintenance records to obtain modification information for different versions of the database in the multi-version database may include:
[0010] Selecting maintenance records corresponding to the same database from the historical maintenance records of the database based on the database unique identifier;
[0011] Parse the maintenance records to obtain modification information corresponding to different versions of the database.
[0012] Optionally, constructing upgrade script templates corresponding to different databases according to the modification information includes:
[0013] Determine the database resource modification type to be processed for the current modification record based on the obtained modification information;
[0014] Based on the determined database resource modification type, a preset upgrade script processing engine corresponding to different types of databases is called;
[0015] Build an upgrade script template corresponding to each type based on the upgrade script processing engine.
[0016] Optionally, obtaining a version upgrade request for a target database issued by a user, and parsing the version upgrade request to obtain the target database type and the upgrade version range includes:
[0017] Get the version upgrade request issued by the user;
[0018] Parse the version upgrade request to obtain the unique identifier of the corresponding target database type and the upgrade version number;
[0019] Determine the version value range of the target database based on the unique identifier, and determine the upgrade version interval based on the upgrade version number.
[0020] Optionally, selecting an upgrade script template corresponding to the target database type from the constructed upgrade script templates, screening and sorting the upgrade script templates based on the obtained upgrade version range, and obtaining an upgrade script corresponding to the version upgrade request includes:
[0021] Obtain the type feature code of the target database;
[0022] Select the upgrade script template corresponding to the type of feature code from the built upgrade script templates;
[0023] Get the minimum and maximum version numbers in the upgrade version range;
[0024] The obtained upgrade script templates are filtered based on the minimum version number and the maximum version number, and the filtered upgrade script templates are sorted according to the size of the version number to obtain the final upgrade script corresponding to the version upgrade request.
[0025] According to a second aspect of an embodiment of the present disclosure, an upgrade script generation device for a multi-version database proposed in an embodiment of the present application includes:
[0026] An information acquisition unit is used to acquire maintenance records for a multi-version database, and parse the maintenance records to acquire modification information for different versions of the database;
[0027] A template building unit is used to build upgrade script templates corresponding to different databases based on the modification information;
[0028] A request parsing unit is used to obtain a version upgrade request for a target database issued by a user, and parse the version upgrade request to obtain the target database type and upgrade version range;
[0029] The script construction unit is used to select an upgrade script template corresponding to the target database type from the constructed upgrade script templates, filter and sort the upgrade script templates based on the obtained upgrade version range, and obtain an upgrade script corresponding to the version upgrade request.
[0030] Optionally, the information acquisition unit includes:
[0031] The data acquisition subunit is used to select maintenance records corresponding to the same database from the historical maintenance records of the database based on the unique identifier of the database;
[0032] The information acquisition subunit is used to parse the maintenance records and obtain the modification information corresponding to different versions of the database.
[0033] Optionally, the template construction unit includes:
[0034] A type determination subunit, configured to determine the database resource modification type to be processed for the current modification record based on the obtained modification information;
[0035] The engine selection subunit is used to call the preset upgrade script processing engine corresponding to different types of databases based on the determined database resource modification type;
[0036] The template building subunit is used to build an upgrade script template corresponding to each type according to the upgrade script processing engine.
[0037] Optionally, the request parsing unit includes:
[0038] The request acquisition subunit is used to obtain the version upgrade request issued by the user;
[0039] The identification resolution subunit is used to resolve the version upgrade request to obtain the unique identification of the corresponding target database type and the upgrade version number;
[0040] The interval determination subunit is used to determine the version value range of the target database according to the unique identifier, and determine the upgrade version interval in combination with the upgrade version number.
[0041] Optionally, the script construction unit includes:
[0042] A feature code acquisition subunit is used to obtain a type feature code of a target database;
[0043] The template selection subunit is used to select an upgrade script template corresponding to the type of feature code from the constructed upgrade script templates;
[0044] The version number selection subunit is used to obtain the minimum and maximum version numbers in the upgrade version range;
[0045] The template selection subunit is used to filter the obtained upgrade script templates based on the minimum version number and the maximum version number, sort the filtered upgrade script templates according to the size of the version number, and finally obtain the upgrade script corresponding to the version upgrade request.
[0046] According to a third aspect of the embodiments of the present disclosure, an electronic device provided in the embodiments of the present application includes:
[0047] processor; and
[0048] a memory for storing executable instructions of the processor;
[0049] The processor is configured to execute the steps of the method for generating an upgrade script for a multi-version database by executing the executable instructions.
[0050] According to a fourth aspect of the embodiments of the present disclosure, the embodiments of the present application provide a computer-readable storage medium having a computer program stored thereon, and the computer program is executed by a processor to perform steps of a method for generating an upgrade script for a multi-version database.
[0051] Beneficial effects:
[0052] There is no need to save and maintain upgrade scripts for each version; you can flexibly and freely select the version you want to upgrade, and you can automatically generate upgrade scripts for jump versions. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the technical solution of the present application, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0054] Figure 1 A flowchart of a method for generating an upgrade script for a multi-version database proposed in an embodiment of the present application;
[0055] Figure 2This is a schematic diagram of the structure of an upgrade script generation device for a multi-version database proposed in an embodiment of the present application;
[0056] Figure 3 A schematic diagram of the structure of an electronic device proposed in an embodiment of the present application. DETAILED DESCRIPTION
[0057] In order to make the structure and advantages of the present application clearer, the structure of the present application will be further described below in conjunction with the accompanying drawings.
[0058] Specifically, the upgrade script generation method for a multi-version database proposed in the embodiment of the present application is as follows: Figure 1 Shown, including:
[0059] 11. Obtain maintenance records for the multi-version database, parse the maintenance records to obtain modification information for different versions of the database;
[0060] 12. Build upgrade script templates corresponding to different databases based on the modification information;
[0061] 13. Obtain the version upgrade request for the target database issued by the user, parse the version upgrade request to obtain the target database type and upgrade version range;
[0062] 14. Select an upgrade script template corresponding to the target database type from the constructed upgrade script templates, filter and sort the upgrade script templates based on the obtained upgrade version range, and obtain an upgrade script corresponding to the version upgrade request.
[0063] In practice, the method for generating a database upgrade script proposed in the embodiment of the present application is mainly divided into two stages. The first is to actively record and store the operation information in the maintenance record as modification information based on the maintenance record of the database during the time interval of the upgrade script generation, and to construct an upgrade script template corresponding to different databases and different versions based on the modification information. The second is to select the required upgrade script from the constructed upgrade script template based on the specific content in the version upgrade request when a version upgrade request is received. Since the constructed upgrade script template stores information corresponding to different types of databases and different versions, the required upgrade script can be directly generated to complete the database upgrade or downgrade operation required in the version upgrade request.
[0064] Specifically, the operation of generating modification information based on the maintenance record in the above solution, i.e., step 11, specifically includes:
[0065] 111. Selecting a maintenance record corresponding to the same database from the historical maintenance records of the database based on the database unique identifier;
[0066] 112. Parse the maintenance record to obtain modification information corresponding to different versions of the database.
[0067] In practice, database maintenance records currently contain two main types of information: structural information and record information. Structural information primarily describes the database's structure, such as table fields, data types, indexes, and other structural information. Record information describes the data records in a database table within the database system. Using database tables as an example, different databases also maintain other database resource information, such as database views and database sequences. Structural information and record information can be maintained simultaneously in a single resource or separately in different resources. Unique identifiers can be used to indicate that the current structural information and record information belong to the same database resource.
[0068] Each time the database is maintained, the generated maintenance record will add a modification record to the structural information. Each modification record will add fixed content settings, such as modification time, modification version, modification order number, modifier, modification content, etc. At the same time, each modification record will correspond to an operation of the database resource structure, such as adding a new table, adding a table field, modifying a table field, adding an index, deleting an index, etc.
[0069] On the other hand, modification records will be added to the data record information, and each modification record will add fixed content settings, such as modification time, modification version, modification order number, modifier, modification content, etc.; at the same time, each modification record will correspond to an operation of the database resource record, such as adding a record, modifying a record, and deleting a record.
[0070] The reference database resource modification record description information is shown in Table 1:
[0071]
[0072] The following are the descriptions of the database resource modification types that can be used as references:
[0073] Modify type properties Property Description Add a new table Indicates that the current table is added based on the current version Add table fields Add one or more table field information to the current table Deleting table fields Delete one or more table field information for the current table Rename table fields Rename one or more table fields for the current table Adding an index Add one or more table index information to the current table Deleting an index Delete one or more table index information for the current table Adding index fields Add an index field to the index information of the current table Deleting an index field Delete the index field for a table index information of the current table Adjust the order of index fields Adjust the order of index fields for a table index information of the current table Adjust index uniqueness Adjust the uniqueness of a table index information for the current table Modify table field type Modify the type of one or more table fields in the current table Modify the index Modify one or more table index information for the current table Modify the table field to be empty Change one or more table fields in the current table to empty attributes
[0074] Table 1
[0075] Optionally, the operation of constructing upgrade script templates corresponding to different databases in the above solution, i.e., step 12, specifically includes:
[0076] 121, determining the database resource modification type to be processed for the current modification record based on the obtained modification information;
[0077] 122. Based on the determined database resource modification type, call a preset upgrade script processing engine corresponding to different types of databases;
[0078] 123. Construct an upgrade script template corresponding to each type according to the upgrade script processing engine.
[0079] In practice, the operation of constructing the upgrade script template in this step is performed based on the structural information and data information obtained in the previous step. According to the different types and contents of the structural information and data information, a preset upgrade script processing engine is called to complete the operation of constructing the upgrade script.
[0080] Before calling the process, it is necessary to determine whether there is a specified database type upgrade script engine. If so, the corresponding database type script generation engine is directly called. The upgrade script engine encapsulates the corresponding database operation script statements according to different database types.
[0081] If it does not exist, determine whether it is necessary to add the required database type upgrade script engine. If necessary, generate the engine with the corresponding database type script.
[0082] Specifically, during the actual execution process, the main process of the above database type script generation engine generating the upgrade script template is as follows:
[0083] Step 1: Determine the modification mode of the current database resource according to the database type.
[0084] Step 2: Write an upgrade script that matches each type of modification mode, and embed the developed operation script and the current database type into the current device that executes the database script upgrade.
[0085] Step 3: Re-execute the previous operation of generating the database upgrade script.
[0086] Optionally, the operation of parsing the version upgrade request to obtain the target database type and the upgrade version range in the above solution, namely step 13, specifically includes:
[0087] 131, obtain the version upgrade request issued by the user;
[0088] 132, parsing the version upgrade request to obtain a unique identifier corresponding to the target database type and an upgrade version number;
[0089] 133. Determine the version value range of the target database based on the unique identifier, and determine the upgrade version interval based on the upgrade version number.
[0090] In implementation, since the target database type to be upgraded is indicated in the version upgrade request issued by the user, and the type is generally recorded using the database's unique identifier, the type of the target database can be quickly determined based on the unique identifier corresponding to the target database type, which is used to determine the version value range of the target database. For example, the existing version value range of the determined target database is V1.0 to V5.0.
[0091] At the same time, according to the version upgrade request, it is also used to obtain the upgrade version number of the target database. The upgrade version number is used to determine the upgrade version interval as V1.9 to V4.8 in combination with the version value range.
[0092] Optionally, selecting an upgrade script template corresponding to the target database type from the constructed upgrade script templates, screening and sorting the upgrade script templates based on the obtained upgrade version range, and obtaining an upgrade script corresponding to the version upgrade request includes:
[0093] 141, obtaining the type feature code of the target database;
[0094] 142, selecting an upgrade script template corresponding to the type of feature code from the constructed upgrade script templates;
[0095] 143, obtain the minimum and maximum version numbers in the upgrade version range;
[0096] 144 , filtering the obtained upgrade script templates based on the minimum version number and the maximum version number, sorting the filtered upgrade script templates by version number, and finally obtaining the upgrade script corresponding to the version upgrade request.
[0097] In practice, the target database's type signature can be used to identify the upgrade script templates corresponding to each version number in the upgrade version range, such as V1.9 to V4.8, from the constructed upgrade script templates. The upgrade script templates are then sorted from largest to smallest or smallest to largest, based on the minimum version number (V1.9) and the maximum version number (V4.8), ultimately obtaining multiple upgrade scripts corresponding to the version upgrade request.
[0098] An embodiment of the present application provides a method for automatically generating multi-version and multi-database upgrade scripts, which can effectively automatically generate upgrade scripts for corresponding versions of corresponding database systems based on database differences and system version differences. In addition, a graphical generation device is provided for maintaining database data and automatically generating upgrade scripts.
[0099] Example 2
[0100] According to the second aspect of the embodiment of the present disclosure, the upgrade script generation device 2 for a multi-version database proposed in the embodiment of the present application is as follows: Figure 2 Shown, including:
[0101] An information acquisition unit 21 is configured to acquire maintenance records for a multi-version database, and parse the maintenance records to acquire modification information for different versions of the multi-version database.
[0102] The template construction unit 22 is used to construct upgrade script templates corresponding to different databases according to the modification information;
[0103] The request parsing unit 23 is used to obtain a version upgrade request for a target database issued by a user, and parse the version upgrade request to obtain the target database type and the upgrade version range;
[0104] The script construction unit 24 is configured to select an upgrade script template corresponding to the target database type from the constructed upgrade script templates, filter and sort the upgrade script templates based on the obtained upgrade version range, and obtain an upgrade script corresponding to the version upgrade request.
[0105] In practice, the method for generating a database upgrade script proposed in the embodiment of the present application is mainly divided into two stages. The first is to actively record and store the operation information in the maintenance record as modification information based on the maintenance record of the database during the time interval of the upgrade script generation, and to construct an upgrade script template corresponding to different databases and different versions based on the modification information. The second is to select the required upgrade script from the constructed upgrade script template based on the specific content in the version upgrade request when a version upgrade request is received. Since the constructed upgrade script template stores information corresponding to different types of databases and different versions, the required upgrade script can be directly generated to complete the database upgrade or downgrade operation required in the version upgrade request.
[0106] Specifically, the information acquisition unit 21 for performing the operation of generating modification information based on the maintenance record in the above solution includes:
[0107] The data acquisition subunit 211 is used to select maintenance records corresponding to the same database from the historical maintenance records of the database based on the database unique identifier;
[0108] The information acquisition subunit 212 is used to parse the maintenance record to obtain modification information corresponding to different versions of the database.
[0109] In practice, database maintenance records currently contain two main types of information: structural information and record information. Structural information primarily describes the database's structure, such as table fields, data types, indexes, and other structural information. Record information describes the data records in a database table within the database system. Using database tables as an example, different databases also maintain other database resource information, such as database views and database sequences. Structural information and record information can be maintained simultaneously in a single resource or separately in different resources. Unique identifiers can be used to indicate that the current structural information and record information belong to the same database resource.
[0110] Each time the database is maintained, the generated maintenance record will add a modification record to the structural information. Each modification record will add fixed content settings, such as modification time, modification version, modification order number, modifier, modification content, etc. At the same time, each modification record will correspond to an operation of the database resource structure, such as adding a new table, adding a table field, modifying a table field, adding an index, deleting an index, etc.
[0111] On the other hand, modification records will be added to the data record information, and each modification record will add fixed content settings, such as modification time, modification version, modification order number, modifier, modification content, etc.; at the same time, each modification record will correspond to an operation of the database resource record, such as adding a record, modifying a record, and deleting a record.
[0112] The reference database resource modification record description information is shown in Table 1:
[0113]
[0114]
[0115] The following are the descriptions of the database resource modification types that can be used as references:
[0116] Modify type properties Property Description Add a new table Indicates that the current table is added based on the current version Add table fields Add one or more table field information to the current table Deleting table fields Delete one or more table field information for the current table Rename table fields Rename one or more table fields for the current table Adding an index Add one or more table index information to the current table Deleting an index Delete one or more table index information for the current table Adding index fields Add an index field to the index information of the current table Deleting an index field Delete the index field for a table index information of the current table Adjust the order of index fields Adjust the order of index fields for a table index information of the current table Adjust index uniqueness Adjust the uniqueness of a table index information for the current table Modify table field type Modify the type of one or more table fields in the current table Modify the index Modify one or more table index information for the current table Modify the table field to be empty Change one or more table fields in the current table to empty attributes
[0117] Table 1
[0118] Optionally, the template construction unit 22 that executes the operation of constructing upgrade script templates corresponding to different databases includes:
[0119] Type determination subunit 221, used to determine the database resource modification type to be processed of the current modification record according to the obtained modification information;
[0120] The engine selection subunit 222 is used to call the preset upgrade script processing engine corresponding to different types of databases based on the determined database resource modification type;
[0121] The template construction subunit 223 is used to construct an upgrade script template corresponding to each type according to the upgrade script processing engine.
[0122] In practice, the operation of constructing the upgrade script template in this step is performed based on the structural information and data information obtained in the previous step. According to the different types and contents of the structural information and data information, a preset upgrade script processing engine is called to complete the operation of constructing the upgrade script.
[0123] Before calling the process, it is necessary to determine whether there is a specified database type upgrade script engine. If so, the corresponding database type script generation engine is directly called. The upgrade script engine encapsulates the corresponding database operation script statements according to different database types.
[0124] If it does not exist, determine whether it is necessary to add the required database type upgrade script engine. If necessary, generate the engine with the corresponding database type script.
[0125] Specifically, during the actual execution process, the main process of the above database type script generation engine generating the upgrade script template is as follows:
[0126] Step 1: Determine the modification mode of the current database resource according to the database type.
[0127] Step 2: Write an upgrade script that matches each type of modification mode, and embed the developed operation script and the current database type into the current device that executes the database script upgrade.
[0128] Step 3: Re-execute the previous operation of generating the database upgrade script.
[0129] Optionally, the request parsing unit 23 includes:
[0130] The request acquisition subunit 231 is used to acquire the version upgrade request issued by the user;
[0131] The identifier resolution subunit 232 is used to resolve the version upgrade request to obtain a unique identifier corresponding to the target database type and an upgrade version number;
[0132] The interval determination subunit 233 is used to determine the version value range of the target database according to the unique identifier, and determine the upgrade version interval in combination with the upgrade version number.
[0133] In implementation, since the target database type to be upgraded is indicated in the version upgrade request issued by the user, and the type is generally recorded using the database's unique identifier, the type of the target database can be quickly determined based on the unique identifier corresponding to the target database type, which is used to determine the version value range of the target database. For example, the existing version value range of the determined target database is V1.0 to V5.0.
[0134] At the same time, according to the version upgrade request, it is also used to obtain the upgrade version number of the target database. The upgrade version number is used to determine the upgrade version interval as V1.9 to V4.8 in combination with the version value range.
[0135] Optionally, the script construction unit 24 includes:
[0136] The feature code acquisition subunit 241 is used to obtain the type feature code of the target database;
[0137] The template selection subunit 242 is used to select an upgrade script template corresponding to the type feature code from the constructed upgrade script templates;
[0138] The version number selection subunit 243 is used to obtain the minimum version number and the maximum version number in the upgrade version range;
[0139] The template selection subunit 244 is used to filter the obtained upgrade script templates based on the minimum version number and the maximum version number, sort the filtered upgrade script templates by version number, and finally obtain the upgrade script corresponding to the version upgrade request.
[0140] In practice, the target database's type signature can be used to identify the upgrade script templates corresponding to each version number in the upgrade version range, such as V1.9 to V4.8, from the constructed upgrade script templates. The upgrade script templates are then sorted from largest to smallest or smallest to largest, based on the minimum version number (V1.9) and the maximum version number (V4.8), ultimately obtaining multiple upgrade scripts corresponding to the version upgrade request.
[0141] An embodiment of the present application provides a device for automatically generating multi-version and multi-database upgrade scripts, which can effectively automatically generate upgrade scripts for corresponding versions of corresponding database systems based on database differences and system version differences. In addition, a graphical generation device is provided for maintaining database data and automatically generating upgrade scripts.
[0142] Example 3
[0143] According to a third aspect of an embodiment of the present disclosure, this embodiment provides an electronic device, including:
[0144] processor; and
[0145] a memory for storing executable instructions of the processor;
[0146] The processor is configured to execute the steps of the method for generating an upgrade script for a multi-version database by executing the executable instructions.
[0147] According to a fourth aspect of an embodiment of the present disclosure, this embodiment provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to perform steps of a method for generating an upgrade script for a multi-version database.
[0148] It should be noted that although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiment of the present disclosure, the features and functions of two or more modules or units described above can be concretized in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into multiple modules or units for concretization. The components displayed as modules or units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the disclosed solution. Those of ordinary skill in the art can understand and implement it without paying any creative work.
[0149] This example embodiment also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method for generating an upgrade script for a multi-version database described in any of the above-described embodiments. The specific steps of the method for generating an upgrade script for a multi-version database can be referenced to the detailed description of the data processing steps in the previous embodiments and are not further described here. The computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, or optical data storage device.
[0150] This example embodiment also provides an electronic device that may include a processor and a memory for storing executable instructions for the processor. The processor is configured to execute the executable instructions to perform the steps of the method for generating an upgrade script for a multi-version database described in any of the above embodiments. The steps of this generation method can be described in detail in the aforementioned method embodiments and will not be repeated here.
[0151] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.
[0152] Figure 3 Schematic diagram of an electronic device according to an exemplary embodiment of the present disclosure. For example, the device can be provided as a server or a client. Figure 3The device includes a processing component 422, which further includes one or more processors, and a memory resource represented by a memory 432 for storing instructions, such as an application, that can be executed by the processing component 422. The application stored in the memory 432 can include one or more modules, each corresponding to a set of instructions. In addition, the processing component 422 is configured to execute the instructions to perform the above-described method.
[0153] The device 800 may also include a power supply component 426 configured to perform power management of the device 400, a wired or wireless network interface 450 configured to connect the device 400 to a network, and an input / output (I / O) interface 458. The device 800 may operate based on an operating system stored in the memory 432, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, or the like.
[0154] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the invention disclosed herein. The examples are intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the appended claims.
Claims
1. A method for generating an upgrade script for a multi-version database, characterized in that: The generation method comprises: Obtain maintenance records for multi-version databases, parse the maintenance records to obtain modification information for different versions of the database; Build upgrade script templates corresponding to different databases based on the modification information; Obtain the version upgrade request for the target database issued by the user, parse the version upgrade request to obtain the target database type and upgrade version range; Select an upgrade script template corresponding to the target database type from the constructed upgrade script templates, filter and sort the upgrade script templates based on the obtained upgrade version range, and obtain an upgrade script corresponding to the version upgrade request; The upgrade script templates corresponding to different databases are constructed according to the modification information, including: Determine the database resource modification type to be processed for the current modification record based on the obtained modification information; Based on the determined database resource modification type, a preset upgrade script processing engine corresponding to different types of databases is called; Build upgrade script templates corresponding to each type based on the upgrade script processing engine; Also includes: Obtain the type feature code of the target database; Select the upgrade script template corresponding to the type of feature code from the built upgrade script templates; Get the minimum and maximum version numbers in the upgrade version range; The obtained upgrade script templates are filtered based on the minimum version number and the maximum version number, and the filtered upgrade script templates are sorted according to the size of the version number to obtain the final upgrade script corresponding to the version upgrade request.
2. The upgrade script generation method for a multi-version database according to claim 1, characterized in that: The obtaining of maintenance records for the multi-version database and parsing of the maintenance records to obtain modification information for different versions of the multi-version database include: Selecting maintenance records corresponding to the same database from the historical maintenance records of the database based on the database unique identifier; Parse the maintenance records to obtain modification information corresponding to different versions of the database.
3. The upgrade script generation method for a multi-version database according to claim 1, characterized in that: The step of obtaining a version upgrade request for a target database issued by a user and parsing the version upgrade request to obtain the target database type and the upgrade version range includes: Get the version upgrade request issued by the user; Parse the version upgrade request to obtain the unique identifier of the corresponding target database type and the upgrade version number; Determine the version value range of the target database based on the unique identifier, and determine the upgrade version interval based on the upgrade version number.
4. An upgrade script generation device for a multi-version database, characterized in that: The generating device comprises: An information acquisition unit is used to acquire maintenance records for a multi-version database, and parse the maintenance records to acquire modification information for different versions of the database; A template building unit is used to build upgrade script templates corresponding to different databases based on the modification information; A request parsing unit is used to obtain a version upgrade request for a target database issued by a user, and parse the version upgrade request to obtain the target database type and upgrade version range; A script construction unit is used to select an upgrade script template corresponding to the target database type from the constructed upgrade script templates, filter and sort the upgrade script templates based on the obtained upgrade version range, and obtain an upgrade script corresponding to the version upgrade request; The template construction unit comprises: A type determination subunit, configured to determine the database resource modification type to be processed for the current modification record based on the obtained modification information; The engine selection subunit is used to call the preset upgrade script processing engine corresponding to different types of databases based on the determined database resource modification type; The template building subunit is used to build an upgrade script template corresponding to each type according to the upgrade script processing engine; The script construction unit includes: A feature code acquisition subunit is used to obtain a type feature code of a target database; The template selection subunit is used to select an upgrade script template corresponding to the type of feature code from the constructed upgrade script templates; The version number selection subunit is used to obtain the minimum and maximum version numbers in the upgrade version range; The template selection subunit is used to filter the obtained upgrade script templates based on the minimum version number and the maximum version number, sort the filtered upgrade script templates according to the size of the version number, and finally obtain the upgrade script corresponding to the version upgrade request.
5. The upgrade script generation device for a multi-version database according to claim 4, characterized in that: The information acquisition unit includes: The data acquisition subunit is used to select maintenance records corresponding to the same database from the historical maintenance records of the database based on the unique identifier of the database; The information acquisition subunit is used to parse the maintenance records and obtain the modification information corresponding to different versions of the database.
6. The upgrade script generation device for a multi-version database according to claim 4, characterized in that: The request parsing unit includes: The request acquisition subunit is used to obtain the version upgrade request issued by the user; The identification resolution subunit is used to resolve the version upgrade request to obtain the unique identification of the corresponding target database type and the upgrade version number; The interval determination subunit is used to determine the version value range of the target database according to the unique identifier, and determine the upgrade version interval in combination with the upgrade version number.
7. An electronic device, characterized in that: include: processor; as well as a memory for storing executable instructions of the processor; The processor is configured to execute the steps of the method for generating an upgrade script for a multi-version database according to any one of claims 1 to 3 by executing the executable instructions.
8. A computer-readable storage medium, characterized in that A computer program is stored thereon, and the computer program is used by a processor to execute the steps of the upgrade script generation method for a multi-version database according to any one of claims 1 to 3.
Citation Information
Patent Citations
Database updating device and database updating method
CN104572644A
Method and device for controlling version change of database
CN111708764A