Database change method and device, equipment, storage medium and program product

By checking and executing change operation instructions in large information technology systems for each test environment, the problem of inconsistent changes in database structures in different test environments is solved, the accuracy and efficiency of changes are improved, and the stability and reliability of the system are enhanced.

CN119690978APending Publication Date: 2025-03-25MASHANG CONSUMER FINANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411720392.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-27
Publication Date
2025-03-25

AI Technical Summary

Technical Problem

In large information technology systems, database structure changes in each test environment may be inconsistent, resulting in complex database change process.

Method used

By determining the change script for the change task, parsing it into specific change operation instructions, and verifying it for each test environment, ensuring that the change operation instructions are executed when the verification is passed.

Benefits of technology

Improve the accuracy and efficiency of database changes, ensure that the database changes results in each test environment are consistent, thereby improving the stability and reliability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119690978A_ABST
    Figure CN119690978A_ABST
Patent Text Reader

Abstract

The invention relates to a database changing method and device, equipment, a storage medium and a program product. The database changing method comprises the steps that a changing script of a first changing task is determined, the first changing task comprises changing operation on a database in a first system, the first system is provided with at least two testing environments, and each testing environment corresponds to at least one database; analyzing the change script to obtain a change operation instruction of the database; and aiming at each test environment, checking the change operation instruction, and executing the change operation instruction on the corresponding database in the test environment under the condition that the change operation instruction passes the checking. Therefore, the reliability of database change in different test environments can be ensured while the change efficiency is improved, the execution of wrong change operation instructions or the execution omission of the change operation instructions can be avoided, the consistency among different test environments can be kept, and the test efficiency and the test scene coverage rate can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of data processing technology, and in particular, to a database change method, apparatus, device, storage medium and program product. Background Art

[0002] In large-scale information technology systems, in order to test different functions of the system at the same time, independent test environments are usually used in parallel. Different test environments have different maintenance personnel and make different adjustments during the test process. Therefore, when the verified functions are released in each test environment of the system, the structural changes required for the databases in different test environments may not be consistent, which makes the process of changing the databases in all test environments of the system more complicated. Summary of the invention

[0003] The purpose of the present disclosure is to provide a database change method, apparatus, device, storage medium and program product, by executing change operation instructions on the database corresponding to the test environment for each test environment when the change operation instruction verification passes, to ensure the accuracy of database changes in different test environments, thereby improving subsequent test efficiency and test scenario coverage, as well as system stability and reliability.

[0004] In order to achieve the above object, the present disclosure provides a database modification method in a first aspect, comprising: Determine a change script for a first change task, wherein the first change task includes a change operation on a database in a first system, wherein the first system is provided with at least two test environments, and each test environment corresponds to at least one database; Parsing the change script to obtain a change operation instruction for the database; For each of the test environments, the change operation instruction is verified, and if the change operation instruction passes the verification, the change operation instruction is executed on the corresponding database in the test environment.

[0005] A second aspect of the present disclosure provides a database modification device, comprising: A determination module, configured to determine a change script of a first change task, wherein the first change task includes a change operation on a database in a first system, wherein the first system is provided with at least two test environments, and each test environment corresponds to at least one database; A parsing module, used to parse the change script to obtain a change operation instruction for the database; The verification change module is used to verify the change operation instruction for each test environment, and if the change operation instruction passes the verification, execute the change operation instruction on the corresponding database in the test environment.

[0006] The third aspect of the present disclosure provides a computer-readable storage medium, on which a computer program is stored, and computer program instructions are stored thereon. When the program instructions are executed by a processor, the steps of the database change method provided in the first aspect of the present disclosure are implemented.

[0007] A fourth aspect of the present disclosure provides an electronic device, including: a memory having a computer program stored thereon; The processor is used to execute the computer program in the memory to perform the steps of the database change method provided in the first aspect of the present disclosure.

[0008] A fifth aspect of the present disclosure provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the database change method provided in the first aspect of the present disclosure.

[0009] In the above technical solution, the first system is provided with at least two test environments, each test environment corresponds to at least one database, and in the process of changing the database, first, the change script of the first change task is determined, and the first change task includes the change operation of the database in the first system; secondly, the change script is parsed to obtain the change operation instruction of the database; then, for each test environment, the change operation instruction is verified, and when the change operation instruction verification passes, the change operation instruction is executed on the corresponding database in the test environment. In this way, by determining the change script of the first change task and parsing it into a specific change operation instruction, the accuracy and integrity of the change operation can be ensured; by verifying the change instruction, invalid operations can be avoided and the change efficiency can be improved; by executing the change operation instruction on the database corresponding to the test environment when the change operation instruction verification passes for each test environment, the accuracy of the database change results in each test environment can be ensured, and the execution of the wrong change operation instruction or the omission of the execution of the change operation instruction can be avoided, which helps to maintain the consistency between different test environments, so as to effectively improve the subsequent test efficiency and test scenario coverage, thereby improving the stability and reliability of the first system.

[0010] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present disclosure but do not constitute a limitation of the present disclosure. In the accompanying drawings: Figure 1 The figure is a flowchart of a method for changing a database according to an exemplary embodiment.

[0012] Figure 2 The figure is a flowchart of a method for changing a database according to an exemplary embodiment.

[0013] Figure 3 The diagram is a schematic diagram showing a database change process according to an exemplary embodiment.

[0014] Figure 4 The figure is a block diagram of a database changing device according to an exemplary embodiment.

[0015] Figure 5 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0016] The specific implementation of the present disclosure is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described herein is only used to illustrate and explain the present disclosure, and is not used to limit the present disclosure.

[0017] The specific implementation of the present disclosure is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described herein is only used to illustrate and explain the present disclosure, and is not used to limit the present disclosure.

[0018] Figure 1 FIG. 1 is a flowchart of a database modification method according to an exemplary embodiment. The method can be applied to a server of a large information technology system. Figure 1 As shown, the method includes steps S101 to S103.

[0019] In step S101 , a change script of a first change task is determined.

[0020] The first change task includes a change operation on a database in the first system. The first system is provided with at least two test environments, and each test environment corresponds to at least one database.

[0021] For example, multiple test environments are set up under the first system, and each test environment may correspond to at least one database. Different test environments under the system may correspond to databases with the same name or databases with different names. Wherein, a test environment corresponding to a database indicates that the test environment includes the database, and a test environment not corresponding to a database indicates that the test environment does not include the database.

[0022] When initially establishing multiple test environments under the first system, although different test environments have different functions to be implemented, there may be overlapping functions or data, so the content of the same database may be copied to different test environments. In order to facilitate traceability and unified changes, the same name is set for these databases with the same initial content. Each test environment is independent, so the database changes in each test environment are independent, that is, changes to a database in the current test environment will not cause changes to the database with the same name in other test environments under the same system. For example, the first system is set up with test environment A and test environment B. Test environment A corresponds to database a, database c, and database d, and test environment B corresponds to database b and database c. Changes to database c in test environment A will not change database c in test environment B.

[0023] For example, the change script of the first change task can be used to indicate the database change operation for the to-be-released function of the first system. The change script of the first change task can be determined when a change instruction is received, wherein the change instruction can be issued by relevant personnel through a user terminal, or the change instruction can also be generated regularly. The change instruction may include information for indicating the change time range. When a change instruction is received, the server can connect to the change management system database through a pre-built query device, and obtain the change script of the change task within the change time range from the change management system database, and the obtained change task can be determined as the first change task, or, in order to avoid repeating the change task that has been executed before, the change task obtained from the change management system database can be deduplicated, and the deduplicated change task can be determined as the first change task.

[0024] Specifically, each change task may correspond to a change task sequence code. If the change task sequence code of the obtained change task already exists in the historical information of the data change and the execution status is executed, then it can be determined that the change task is not the first change task of this database change; if the change task sequence code of the obtained change task does not exist in the historical information of the data change, or the change task sequence code of the obtained change task already exists in the historical information of the data change, but the execution status is not executed, then the change task can be determined as the first change task of this database change.

[0025] In step S102, the change script is parsed to obtain a database change operation instruction.

[0026] For example, the change script may be a SQL (Structured Query Language) script, which may be parsed by a pre-built change parser to obtain a change operation instruction for the database under the first system. The change operation instruction involved in the present disclosure may be used to implement a change to the structure of a database. For example, the change operation instruction may indicate adding a new database or deleting a database. For another example, the change operation instruction may indicate adding a new data table or deleting a data table in a database, or adding a new field, deleting a field, or modifying a field in a data table.

[0027] In step S103, the change operation instruction is verified for each test environment, and the change operation instruction is executed on the database corresponding to the test environment if the change operation instruction verification passes.

[0028] For example, the verification of the change operation instruction can be realized through a pre-built library table verifier. The library table verifier can parse each change operation instruction to obtain operation keywords such as add, delete, modify, and the database name, data table name, field name, and field attribute of the operation object; and can verify the change operation instruction based on the keywords and operation objects obtained by parsing.

[0029] If the change operation instruction is verified to be passed, the script executor can be controlled to connect to the database according to the current test environment and database name, and automatically execute the change operation instruction. Among them, the correspondence between each test environment and the database can be pre-sorted and stored to achieve database connection. Furthermore, in order to ensure the legality of the execution of the change operation instruction and improve data security, the script executor can perform user identity authentication through account information before connecting to the database. If the user identity authentication is passed, the database link is performed according to the current test environment and database name, and the change operation instruction is automatically executed.

[0030] Different test environments may include databases with different names, and during the test process, relevant personnel may make different adjustments to databases with the same name in different test environments, resulting in different structures of databases with the same name in different test environments. Therefore, when the same change operation instruction is obtained, the database changes required in different test environments may not be consistent. For each test environment, the change operation instruction is verified before executing the change operation instruction, which can avoid executing invalid change operation instructions on the database corresponding to the test environment, thereby improving the change efficiency.

[0031] For example, there is database a in test environment A, but there is no database a in test environment B, and the change operation instruction is used to add database a. At this time, for test environment A, because database a already exists, the change operation instruction verification fails, avoiding unnecessary change operation instructions for the database corresponding to test environment A; for test environment B, the change operation instruction verification passes, and database a can be added in test environment B to implement the change.

[0032] For another example, there are databases c in both test environments A and B, and the change operation instruction is used to add a new data table table1 in database c. Database c in test environment A is not affected by the debugging of test environment B, and database c in test environment B is not affected by the debugging of test environment A. If there is no table1 in database c in test environment A and database c in test environment B, then the change operation instruction is verified to pass for both test environments A and B, and data table table1 can be added to database c in test environment A and database c in test environment B. If there is already table1 in database c in test environment A and there is no table1 in database c in test environment B, then the change operation instruction for test environment A fails to pass the verification, avoiding unnecessary execution of change operation instructions on the database corresponding to test environment A. For test environment B, the change operation instruction passes the verification, so that data table table1 is added to database c to implement the change.

[0033] For each test environment in turn, the verified change operation instructions are executed on the database corresponding to the test environment, which can realize the database changes of different test environments under the first system, ensure the accuracy of database changes in each test environment, avoid executing erroneous change operation instructions, or omit the execution of change operation instructions, which helps to maintain consistency between different test environments. In this way, the test efficiency and test scenario coverage of the first system in the subsequent process can be improved, and the stability and reliability of the first system can be improved.

[0034] In the above technical solution, the first system is provided with at least two test environments, each test environment corresponds to at least one database, and in the process of changing the database, first, the change script of the first change task is determined, and the first change task includes the change operation of the database in the first system; secondly, the change script is parsed to obtain the change operation instruction of the database; then, for each test environment, the change operation instruction is verified, and when the change operation instruction verification passes, the change operation instruction is executed on the corresponding database in the test environment. In this way, by determining the change script of the first change task and parsing it into a specific change operation instruction, the accuracy and integrity of the change operation can be ensured; by verifying the change instruction, invalid operations can be avoided and the change efficiency can be improved; by executing the change operation instruction on the database corresponding to the test environment when the change operation instruction verification passes for each test environment, the accuracy of the database change results in each test environment can be ensured, and the execution of the wrong change operation instruction or the omission of the execution of the change operation instruction can be avoided, which helps to maintain the consistency between different test environments, so as to effectively improve the subsequent test efficiency and test scenario coverage, thereby improving the stability and reliability of the first system.

[0035] In the present disclosure, a plurality of test environments are provided under the first system, and each test environment may correspond to at least one database, wherein each database may include a data table, and the data table may include fields. The verification of the change operation instruction may be implemented through the embodiments provided below.

[0036] In an optional embodiment, in step S103, for each test environment, the change operation instruction is verified, including: If the change operation instruction indicates to delete the first database, and the test environment corresponds to the first database, a confirmation prompt message is generated, and the confirmation prompt message is used to request the user to confirm whether to execute the operation of deleting the first database; If the user confirms the execution of the operation instruction to delete the first database, it is determined that the change operation instruction passes the verification.

[0037] For example, by comparing the library names of the first database in the change operation instruction and the database corresponding to the test environment, it can be determined whether the test environment corresponds to the first database. If there is a database with the same name as the first database in the database corresponding to the test environment, it can be determined that the test environment corresponds to the first database. The process of comparing the library names of the databases is simple, which can effectively improve the judgment efficiency.

[0038] If the test environment does not correspond to the first database, it can be determined that even if the change operation instruction is executed, there is no first database that can be deleted. In order to avoid wasting operating resources, it can be determined that the change operation instruction has not passed the verification. If the test environment corresponds to the first database, it can be determined that the change operation instruction for indicating the deletion of the first database is valid, but deleting the database is an important operation in the database change process and has a greater impact on the system. In order to avoid mistakenly deleting the database under the test environment, a confirmation prompt message can be generated and sent to the user terminal to confirm whether to execute the operation of deleting the database by the user. If the user confirms that the operation instruction for deleting the first database is not executed, it can be determined that the user does not allow the deletion of the first database, and the change operation instruction has not passed the verification. If the user confirms that the operation instruction for deleting the first database is executed, it can be determined that the user allows the deletion of the first database, and the change operation instruction passes the verification. In this way, by manually verifying the change operation instruction indicating the deletion of the first database, the accidental deletion of the database can be effectively avoided.

[0039] In an optional embodiment, in step S103, for each test environment, the change operation instruction is verified, including: If the change operation instruction indicates to add a second database, then when the test environment does not correspond to the second database, it is determined that the change operation instruction passes the verification.

[0040] The method of determining whether the test environment corresponds to the second database is consistent with the method of determining whether the test environment corresponds to the first database in the previous text, and will not be repeated here.

[0041] For example, if the test environment does not correspond to the second database, it can be determined that executing the change operation instruction will not cause the test environment to correspond to two identical databases, that is, it will not cause database redundancy. At this time, it can be determined that the change operation instruction has passed the verification, so that the second database can be added by executing the change operation instruction in the subsequent process. If the test environment corresponds to the second database, in order to avoid repeatedly setting the same database under the same test environment, it can be determined that the verification has not passed.

[0042] In an optional embodiment, in step S103, for each test environment, the change operation instruction is verified, including: If the change operation instruction indicates to add a first data table in the third database, then when the test environment corresponds to the third database and the third database does not include the first data table, it is determined that the change operation instruction passes the verification.

[0043] By way of example, by comparing the library names of the third database and the database in the test environment, it can be determined whether the test environment corresponds to the third database; by comparing the table names of the first data table and the data table in the third database, it can be determined whether the third database includes the first data table. By way of example, if there is a database with the same name as the third database in the database corresponding to the test environment, it can be determined that the test environment corresponds to the third database; if there is a data table with the same name as the first data table in the third database, it can be determined that the third database includes the first data table. The process of comparing the library names of the databases and comparing the table names of the data tables is relatively simple, which can effectively improve the judgment efficiency.

[0044] If the test environment corresponds to a third database, and the third database does not include the first data table, it can be determined that executing the change operation instruction will not result in repeated setting of the same first data table under the third database of the test environment, that is, it will not result in data table redundancy. At this time, it can be determined that the change operation instruction has passed the verification, so that the first data table can be added by executing the change operation instruction in the subsequent process. If the test environment corresponds to a third database, and the third database includes the first data table, in order to avoid repeatedly setting the same first data table in the third database corresponding to the test environment, it can be determined that the verification has not passed. If the test environment does not correspond to the third database, it can be determined that the location indicated by the change operation instruction does not exist, and the change operation instruction cannot successfully change the database structure. At this time, it can be determined that the change operation instruction has not passed the verification to avoid wasting operating resources.

[0045] In an optional embodiment, in step S103, for each test environment, the change operation instruction is verified, including: If the change operation instruction indicates to delete the second data table in the third database, then when the test environment corresponds to the third database and the third database includes the second data table, it is determined that the change operation instruction passes the verification.

[0046] The method of determining whether the third database includes the second data table is consistent with the method of determining whether the third database includes the first data table in the previous text, and will not be repeated here.

[0047] If the test environment corresponds to the third database, and the third database includes the second data table, it can be determined that there is a second data table that can be deleted at the location indicated by the change operation instruction, and the change operation instruction is a valid instruction. At this time, it can be determined that the change operation instruction has passed the verification, so that the second data table can be deleted by executing the change operation instruction in the subsequent process. If the test environment corresponds to the third database, and the third database does not include the second data table, it can be determined that there is no second data table that can be deleted at the location indicated by the change operation instruction; or if the test environment does not correspond to the third database, it can be determined that the location indicated by the change operation instruction does not exist. In both cases, the change operation instruction used to instruct the deletion of the second data table in the third database is an invalid instruction. Even if this change operation instruction is executed in the subsequent process, the database structure cannot be successfully changed. At this time, it can be determined that the change operation instruction verification has not passed to avoid wasting operating resources.

[0048] In an optional embodiment, in step S103, for each test environment, the change operation instruction is verified, including: If the change operation instruction indicates to delete the first field in the third data table in the fourth database, then when the test environment corresponds to the fourth database, the fourth database includes the third data table, and the third data table includes the first field, it is determined that the change operation instruction passes the verification.

[0049] Among them, determining whether the test environment corresponds to the fourth database is consistent with the method of determining whether the test environment corresponds to the first database in the previous text, and determining whether the fourth database includes the third data table is consistent with the method of determining whether the third database includes the first data table in the previous text, which will not be repeated here. For example, by comparing the first field and the field name of the field in the third data table in the fourth database, it can be determined whether the third data table includes the first field. For example, if the third data table includes a field with the same field name as the first field, it is determined that the third data table includes the first field. In this way, it can be simply and quickly determined whether the third data table includes the first field.

[0050] If the test environment corresponds to a fourth database, the fourth database includes a third data table, and the third data table includes a first field, then it can be determined that there is a first field that can be deleted at the position indicated by the change operation instruction, and the change operation instruction is a valid instruction. At this time, it can be determined that the change operation instruction has passed the verification, so that the first field can be deleted by executing the change operation instruction in the subsequent process.

[0051] When the test environment corresponds to the fourth database, the fourth database includes the third data table but the third data table does not include the first field, it can be determined that the first field that can be deleted does not exist at the location indicated by the change operation instruction; when the test environment corresponds to the fourth database but the fourth database does not include the third data table, or when the test environment does not correspond to the fourth database, it can be determined that the location indicated by the change operation instruction does not exist. In these three cases, the change operation instruction for instructing to delete the first field in the third data table in the fourth database is an invalid instruction. Even if this change operation instruction is executed in the subsequent process, the database structure cannot be successfully changed. At this time, it can be determined that the change operation instruction verification has not passed to avoid wasting operating resources.

[0052] In an optional embodiment, in step S103, for each test environment, the change operation instruction is verified, including: If the change operation instruction indicates to add a second field in the third data table in the fourth database, then if the test environment corresponds to the fourth database, the fourth database includes the third data table, and the third data table does not include a field with the same field name and field attributes as the second field, it is determined that the change operation instruction has passed the verification.

[0053] The field attributes include at least one of the data type of the data corresponding to the field, the field length, the field non-null constraint, whether the field is auto-incremented, the field default value, and primary key information representing whether the field is a primary key.

[0054] The data type of the data corresponding to the field is used to define the data type that the field can store, such as integers, floating point numbers, strings, dates, etc.; the field length is used to define the amount of data that the field can store; the field non-null constraint is used to indicate whether the field can be a non-null value, that is, whether the field must contain a value, that is, whether the field is allowed to be empty; whether the field is auto-incremented, used to control the database to automatically generate a unique numeric identifier for new records, for example, whenever a new record is inserted, the value of the field will automatically increase; the field default value is used to specify the value that a field should use when no explicit value is assigned. The primary key information that represents whether the field is a primary key is used to indicate whether the field is a primary key field or a non-primary key field.

[0055] For example, by comparing the field names and field attributes, it can be determined whether the third data table includes fields that are completely identical to the second field. In this way, it can be more accurately determined whether the fields are identical, thereby improving the reliability of the determination result.

[0056] For example, determine whether the third data table includes a field with the same field name and field attributes as the second field in the following manner: determine whether the third data table includes a field with the same field name as the second field; if the third data table does not include a field with the same field name as the second field, determine whether the third data table includes a field with the same field name as the second field and the same field attributes as the second field; if the third data table includes a field with the same field name as the second field, determine whether the third data table includes a field with the same field name and field attributes as the second field, if not, determine that the third data table does not include a field with the same field name and field attributes as the second field, and if included, determine that the third data table includes a field with the same field name and field attributes as the second field. In this way, the comparison process can be simplified by giving priority to comparing the field names. In the case where the field names are the same, further comparing the field attributes can more efficiently and accurately determine whether the fields are the same.

[0057] When the test environment corresponds to the fourth database, the fourth database includes the third data table, and the third data table does not include a field with the same field name and field attributes as the second field, it can be determined that executing the change operation instruction will not result in the existence of two completely identical second fields under the third data table of the fourth database of the test environment, that is, it will not cause field redundancy. At this time, it can be determined that the change operation instruction has passed the verification, so that the addition of the second field can be achieved by executing the change operation instruction in the subsequent process.

[0058] When the test environment corresponds to the fourth database, the fourth database includes the third data table, and the third data table includes a field with the same field name and field attribute as the second field, in order to avoid setting the same second field under the third data table of the fourth database of the test environment, it can be determined that the verification has not passed. When the test environment does not correspond to the fourth database, or when the test environment corresponds to the fourth database but the fourth database does not include the third data table, it can be determined that the location indicated by the change operation instruction does not exist, and the change operation instruction cannot successfully change the database structure. At this time, it can be determined that the change operation instruction has not passed the verification to avoid wasting operating resources.

[0059] In an optional embodiment, in step S103, for each test environment, the change operation instruction is verified, including: If the change operation instruction indicates that the field attributes of the third field in the third data table in the fourth database are modified to the preset field attributes, then if the test environment corresponds to the fourth database, the fourth database includes the third data table, the third data table includes the third field, and the field attributes of the third field are inconsistent with the preset field attributes, it is determined that the change operation instruction has passed the verification.

[0060] For example, whether the third data table includes the third field can be determined by comparing the third field and the field name of the field in the third data table of the fourth database, and then whether the third field of the third data table needs to be modified can be determined by comparing the field attributes of the third field in the third data table with the preset field attributes.

[0061] If the test environment corresponds to a fourth database, the fourth database includes a third data table, the fourth database includes a third field, and the field attributes of the third field of the third data table are inconsistent with the preset field attributes, then it can be determined that the third field of the third data table needs to be modified. At this time, it can be determined that the change operation instruction has passed the verification, so that the change operation instruction can be executed in the subsequent process to realize the modification of the third field in the third data table.

[0062] If the test environment corresponds to the fourth database, the fourth database includes the third data table, the fourth database includes the third field, and the field attribute of the third field in the third data table is consistent with the preset field attribute, then it can be determined that the third field in the third data table does not need to be modified, and even if this change operation instruction is executed in the subsequent process, the third field in the third data table will not change. At this time, it can be determined that the change operation instruction verification has not passed to avoid wasting operating resources. When the test environment does not correspond to the fourth database, or when the test environment corresponds to the fourth database but the fourth database does not include the third data table, or when the test environment corresponds to the fourth database, the fourth database includes the third data table but the fourth database does not include the third field, it can be determined that the location indicated by the change operation instruction does not exist, and the change operation instruction cannot successfully change the database structure. At this time, it can be determined that the change operation instruction verification has not passed to avoid wasting operating resources.

[0063] In an optional embodiment, before verifying the change operation instruction for each test environment, the database change method provided by the present disclosure may further include: When there are multiple change operation instructions, the change operation instructions are sorted according to the dependency relationship between the change operation instructions.

[0064] For example, the change operation instruction includes the following: int array

[10] ; int value = array[index]; The assignment of value depends on the value of index and whether array has been correctly initialized and filled. Therefore, there is a data dependency between the two change operation instructions, int array

[10] and int value = array[index]. In addition to the data dependency, there can also be resource dependencies and control dependencies between change operation instructions. For example, the data dependency, resource dependency, and control dependency between each change operation instruction can be analyzed through a pre-built change parser to obtain the dependency between each change operation instruction.

[0065] In an optional embodiment, after the step of sorting the change operation instructions is completed, in step S103, the change operation instructions may be verified in the following manner: For each test environment, the change operation instructions are verified in sequence according to the order of the change operation instructions.

[0066] In this way, by checking the change operation instructions in sequence according to the order of the change operation instructions, resource conflicts can be avoided and dependency requirements between the change operation instructions can be met.

[0067] Figure 2 FIG. 1 is a flowchart of a method for changing a database according to an exemplary embodiment. Figure 2 As shown, the change operation instructions can be sorted according to the method shown in step S1041 to step S1043.

[0068] Step S1041, when there are multiple change operation instructions, determine multiple first change operation instructions with dependencies and at least one second change operation instruction without dependencies.

[0069] For example, a pre-built change parser can be used to determine the execution dependencies of the change operation instructions under the first change task according to the serial conditions in the change script of the current first change task; based on the obtained execution dependencies, the first change operation instruction with a dependency and the second change operation instruction without a dependency can be determined.

[0070] Step S1042: sort the plurality of first change instructions according to the dependency relationship.

[0071] Step S1043: randomly insert at least one second change operation instruction between the sorted first change instructions.

[0072] For example, the first change operation instruction as the dependent party can be placed after the first change operation instruction as the dependent party, and then the second change operation instruction can be randomly inserted between the sorted multiple first change instructions to obtain the dependency link order, that is, the sorting result.

[0073] For example, there are three change operation instructions under the first change task, change operation instruction 1 depends on change operation instruction 2, and change operation instruction 3 has no dependency relationship with the other two. Whether change operation instruction 3 is executed between change operation instruction 1 and change operation instruction 2, or before or after the two, it does not affect the execution results of change operation instruction 1 and change operation instruction 2. Therefore, when sorting, change operation instruction 2 should be placed before change operation instruction 1, and change operation instruction 3 can be randomly sorted. Therefore, the sorting results can be the following possibilities: 1) Change operation instruction 2, change operation instruction 3, change operation instruction 1; 2) Change operation instruction 3, change operation instruction 2, change operation instruction 1; 3) Change operation instruction 2, change operation instruction 1, change operation instruction 3.

[0074] In an optional embodiment, the database change method provided by the present disclosure may also include: If there are multiple first change tasks, the change operation instructions of each first change task are sorted according to the sorting of each first change task, wherein the higher the sorting of the first change task is, the higher the sorting of the change operation instruction of the first change task is.

[0075] For example, the change operation instructions of each first change task can be sorted based on the time information and / or priority information of each first change task. Specifically, if the time information of the first change task Task1 is earlier than the time information of the first change task Task2, then all the change operation instructions under the first change task Task1 are sorted before all the change operation instructions under the first change task Task1.

[0076] In order to distinguish each first change task, a change task sequence code can be set for each first change task; each change operation instruction can generate an execution sequence code according to the change task sequence code of the first change task to which it belongs and the execution sequence number in the sorting result of the first change task. Then, a change list can be obtained based on the execution sequence code, so that the change operation instructions can be verified in sequence according to the change list in each test environment. In this way, the execution process of database changes can be effectively planned and controlled to avoid erroneous or incomplete change results caused by confusion in the operation sequence.

[0077] For example, the change list may include an execution order code, a change task sequence code, a database to be changed involved in the change process, a data table to be changed, a change operation instruction, and an execution status.

[0078] Taking the two first change tasks with change task sequence code BSJ142024010244101 and change task sequence code BSJ142024010244102 as examples, the first change task with change task sequence code BSJ142024010244101 includes change operation instructions SQL1, SQL2, SQL3, SQL4, SQL5, SQL6 and SQL7, and the first change task with change task sequence code BSJ142024010244102 includes change operation instructions SQL8 and SQL9.

[0079] For the first change task with a change task sequence code of BSJ142024010244101, the sorting process of each change operation instruction can be as follows: The first change operation instructions with dependency relationships are SQL1, SQL2, SQL3, SQL4, SQL5, and SQL6, and the second change operation instruction without dependency relationships is SQL7, among which SQL3 depends on SQL1, SQL2 depends on SQL1, SQL5, and SQL3, and SQL6 depends on SQL4 and SQL1. The sorting process can be as follows: randomly select a change operation instruction, such as SQL1. SQL1 is only a dependent party, that is, it does not depend on other change operation instructions and can be the first in the sequence; then the next change operation instruction can be randomly selected from the remaining change operation instructions, such as SQL2. SQL2 depends on SQL1, SQL5, and SQL3. These three SQLs can be cyclically parsed, among which the order of SQL1 has been advanced and does not need to be processed. SQL5 does not depend on other change operation instructions and is only a dependent party. It can be confirmed that the current order is SQL1->SQL5; SQL3 depends on SQL1, and SQL3 can be placed after SQL5 to determine that the current order is SQL1->SQL5->SQL3. SQL2 depends on SQL1. The order of SQL1, SQL5 and SQL3 has been advanced, so the current order can be determined to be SQL1->SQL5->SQL3->SQL2; next, the next change operation instruction can be randomly selected from the remaining change operation instructions, such as SQL4. SQL4 is only a dependent party and does not depend on other change operation instructions. Therefore, SQL4 can be placed after SQL2 without any other processing, and the current order can be determined to be SQL1->SQL5->SQL3->SQL2->SQL4; then, the next change operation instruction can be randomly selected from the remaining change operation instructions, such as SQL6. SQL6 depends on SQL4 and SQL1, and the order of SQL4 and SQL1 has been advanced. At this time, the current order can be determined to be SQL1->SQL5->SQL3->SQL2->SQL4->SQL6; there is no dependency relationship between the remaining SQL7 and other change operation instructions, so the position of SQL7 can be randomly set, for example, the sorting result of SQL1->SQL5->SQL3->SQL2->SQL4->SQL6->SQL7 can be obtained.

[0080] For the first change task with a change task sequence code of BSJ142024010244102, the sorting process of each change operation instruction can be as follows: SQL8 and SQL9 are both second change operation instructions that do not have a dependency relationship, and the sorting result of SQL8->SQL9 can be obtained.

[0081] The time information of the first change task with the change task sequence code BSJ142024010244101 is earlier than the time information of the first change task with the change task sequence code BSJ142024010244102. Therefore, the change lists of the two first change tasks with the change task sequence code BSJ142024010244101 and the change task sequence code BSJ142024010244102 can be shown in Table 1.

[0082] Table 1

[0083] When generating a change list, the execution status column is all Not Executed. If, in the current test environment, the change operation instruction has passed the verification and has been executed, the execution status of the change operation instruction under the change list of the current test environment can be changed to Executed, so as to facilitate the review of the database change process in the current test environment.

[0084] In addition, considering that the operation of deleting a database requires manual verification, in order to avoid the database being difficult to change for a long time due to slow manual review, the change operation instructions other than those for deleting the database can be sorted.

[0085] Figure 3 is a schematic diagram showing a database change process according to an exemplary embodiment. Figure 3 , the implementation process of the database change method provided by the present disclosure can be more clearly understood. Figure 3 The content above the dotted line can be completed on the server side, and the content below the dotted line can be completed on the user terminal.

[0086] like Figure 3As shown, first set the change time range, then based on the change time range, the first change task can be obtained from the change management system database through the query, wherein the query can also store the basic information of the first change task in the verification library, and the basic information can include the change task sequence code, change script, change operation time, change task execution status, database involved and other information. Then the change script of the first change task can be parsed by the change parser to obtain the change operation instruction to generate a change list, which can also be stored in the verification library. Next, the library table cycle verification can be performed in the test environment 1-M in sequence. The library table cycle verification means that in the current test environment, according to the order of the change list from front to back, the change operation instruction is verified in sequence. Specifically, the change list can be called by the library table verifier to realize the verification. In the case of passing the verification, the script executor can be used to link the database according to the current test environment, database name and account information, and automatically execute the corresponding change operation instruction, and then the change task execution status in the verification library can be changed. After the corresponding change operation instruction is executed, the execution status in the change list under the current environment can be changed based on the execution result.

[0087] When the database table matching in the current test environment is completed, that is, the database change in the current test environment is completed, the database table cyclic verification of the next test environment can be started until the synchronization of all test environments is completed, that is, the database change in all test environments is completed. After that, the change list after the change in each test environment can be sent to the user terminal for manual verification.

[0088] Based on the same inventive concept, the present disclosure also provides a database changing device. Figure 4 FIG. 1 is a block diagram of a database modification device according to an exemplary embodiment. Figure 4 , the database changing device 400 may include: The determination module 401 is used to determine a change script of a first change task, wherein the first change task includes a change operation on a database in a first system, wherein the first system is provided with at least two test environments, and each test environment corresponds to at least one database; The parsing module 402 is used to parse the change script to obtain the change operation instruction of the database; The change verification module 403 is used to verify the change operation instruction for each of the test environments, and if the change operation instruction passes the verification, execute the change operation instruction on the corresponding database in the test environment.

[0089] In this way, by determining the change script of the first change task and parsing it into specific change operation instructions, the accuracy and completeness of the change operation can be ensured; by verifying the change instructions, invalid operations can be avoided and change efficiency can be improved; by executing the change operation instructions on the database corresponding to the test environment for each test environment when the change operation instruction verification passes, the accuracy of the database change results in each test environment can be ensured, avoiding the execution of erroneous change operation instructions or omitting the execution of change operation instructions, which helps to maintain consistency between different test environments, so as to effectively improve subsequent test efficiency and test scenario coverage, and thereby improve the stability and reliability of the first system.

[0090] Optionally, the verification change module 403 is used to verify the change operation instruction in the following manner: If the change operation instruction indicates to delete the first database and the test environment corresponds to the first database, a confirmation prompt message is generated, where the confirmation prompt message is used for the user to confirm whether to execute the operation of deleting the first database; If a user confirmation instruction to execute the operation of deleting the first database is received, it is determined that the change operation instruction has passed the verification.

[0091] Optionally, the verification change module 403 is used to verify the change operation instruction in the following manner: If the change operation instruction indicates to add a second database, then when the test environment does not correspond to the second database, it is determined that the change operation instruction passes the verification.

[0092] Optionally, the change verification module 403 is used to verify the change operation instruction in at least one of the following ways: If the change operation instruction indicates to add a first data table in the third database, then, if the test environment corresponds to the third database and the third database does not include the first data table, determining that the change operation instruction passes verification; If the change operation instruction indicates to delete the second data table in the third database, then when the test environment corresponds to the third database and the third database includes the second data table, it is determined that the change operation instruction passes the verification.

[0093] Optionally, the change verification module 403 is used to verify the change operation instruction in at least one of the following ways: If the change operation instruction indicates to delete the first field in the third data table in the fourth database, then, if the test environment corresponds to the fourth database, the fourth database includes the third data table, and the third data table includes the first field, it is determined that the change operation instruction passes the verification; If the change operation instruction indicates to add a second field to the third data table in the fourth database, then if the test environment corresponds to the fourth database, the fourth database includes the third data table, and the third data table does not include a field having the same field name and field attributes as the second field, it is determined that the change operation instruction passes the verification; If the change operation instruction indicates that the field attributes of the third field in the third data table in the fourth database are modified to the preset field attributes, then when the test environment corresponds to the fourth database, the fourth database includes the third data table, the third data table includes the third field, and the field attributes of the third field are inconsistent with the preset field attributes, it is determined that the change operation instruction has passed the verification.

[0094] Optionally, the field attributes include at least one of the data type of the data corresponding to the field, the field length, the field non-null constraint, whether the field is auto-incremented, the field default value, and primary key information representing whether the field is a primary key.

[0095] Optionally, the database changing device 400 further includes: A dependency determination module, used for determining, when there are multiple change operation instructions, multiple first change operation instructions with dependencies and at least one second change operation instruction without dependencies; A first sorting module, used to sort the plurality of first change instructions according to dependency relationships; A second sorting module, configured to randomly insert the at least one second change operation instruction between the sorted plurality of first change instructions; The verification change module 403 is used to verify the change operation instruction in the following manner: For each of the test environments, the change operation instructions are verified in sequence according to the order of the change operation instructions.

[0096] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0097] Figure 5 6 is a block diagram of an electronic device 600 according to an exemplary embodiment. For example, the electronic device 600 may be provided as a server. Figure 5The electronic device 600 includes a processor 622, which may be one or more, and a memory 632 for storing a computer program executable by the processor 622. The computer program stored in the memory 632 may include one or more modules, each corresponding to a set of instructions. In addition, the processor 622 may be configured to execute the computer program to perform the above-mentioned database change method.

[0098] In addition, the electronic device 600 may further include a power supply component 626 and a communication component 650, wherein the power supply component 626 may be configured to perform power management of the electronic device 600, and the communication component 650 may be configured to implement communication of the electronic device 600, for example, wired or wireless communication. In addition, the electronic device 600 may further include an input / output (I / O) interface 658. The electronic device 600 may operate based on an operating system stored in the memory 632, such as Windows ServerTM, Mac OSXTM, UnixTM, LinuxTM, etc.

[0099] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned database change method are implemented. For example, the computer-readable storage medium can be the above-mentioned memory 632 including program instructions, and the above-mentioned program instructions can be executed by the processor 622 of the electronic device 600 to complete the above-mentioned database change method.

[0100] In another exemplary embodiment, a computer program product is further provided. The computer program product includes a computer program that can be executed by a programmable device. The computer program has a code portion for executing the above database modification method when executed by the programmable device.

[0101] The preferred embodiments of the present disclosure are described in detail above in conjunction with the accompanying drawings; however, the present disclosure is not limited to the specific details in the above embodiments. Within the technical concept of the present disclosure, a variety of simple modifications can be made to the technical solution of the present disclosure, and these simple modifications all fall within the protection scope of the present disclosure.

[0102] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present disclosure will not further describe various possible combinations.

[0103] In addition, various embodiments of the present disclosure may be arbitrarily combined, and as long as they do not violate the concept of the present disclosure, they should also be regarded as the contents disclosed by the present disclosure.

Claims

1. A database modification method, characterized in that: include: Determine a change script for a first change task, wherein the first change task includes a change operation on a database in a first system, wherein the first system is provided with at least two test environments, and each test environment corresponds to at least one database; Parsing the change script to obtain a change operation instruction for the database; For each of the test environments, the change operation instruction is verified, and if the change operation instruction passes the verification, the change operation instruction is executed on the corresponding database in the test environment.

2. The method according to claim 1, characterized in that The step of verifying the change operation instruction for each test environment includes: If the change operation instruction indicates to delete the first database, and the test environment corresponds to the first database, a confirmation prompt message is generated, and the confirmation prompt message is used by the user to confirm whether to execute the operation of deleting the first database; If a user confirmation instruction to execute the operation of deleting the first database is received, it is determined that the change operation instruction has passed the verification.

3. The method according to claim 1, characterized in that The verifying the change operation instruction for each test environment includes: If the change operation instruction indicates to add a second database, then when the test environment does not correspond to the second database, it is determined that the change operation instruction passes the verification.

4. The method according to claim 1, characterized in that The verifying the change operation instruction for each test environment includes at least one of the following: If the change operation instruction indicates to add a first data table in the third database, then, if the test environment corresponds to the third database and the third database does not include the first data table, determining that the change operation instruction passes verification; If the change operation instruction indicates to delete the second data table in the third database, then when the test environment corresponds to the third database and the third database includes the second data table, it is determined that the change operation instruction passes the verification.

5. The method according to claim 1, characterized in that The verifying the change operation instruction for each test environment includes at least one of the following: If the change operation instruction indicates to delete the first field in the third data table in the fourth database, then, if the test environment corresponds to the fourth database, the fourth database includes the third data table, and the third data table includes the first field, it is determined that the change operation instruction passes the verification; If the change operation instruction indicates to add a second field to the third data table in the fourth database, then if the test environment corresponds to the fourth database, the fourth database includes the third data table, and the third data table does not include a field having the same field name and field attributes as the second field, it is determined that the change operation instruction passes the verification; If the change operation instruction indicates that the field attributes of the third field in the third data table in the fourth database are modified to the preset field attributes, then when the test environment corresponds to the fourth database, the fourth database includes the third data table, the third data table includes the third field, and the field attributes of the third field are inconsistent with the preset field attributes, it is determined that the change operation instruction has passed the verification.

6. The method according to claim 5, characterized in that The field attributes include at least one of the data type of the data corresponding to the field, the field length, the field non-null constraint, whether the field is auto-incremented, the field default value, and primary key information representing whether the field is a primary key.

7. The method according to claim 1, characterized in that The method further comprises: In the case where there are multiple change operation instructions, determining multiple first change operation instructions having a dependency relationship and at least one second change operation instruction having no dependency relationship; sorting the plurality of first change instructions according to dependency relationships; randomly inserting the at least one second change operation instruction between the sorted plurality of first change instructions; The step of verifying the change operation instruction for each test environment includes: For each of the test environments, the change operation instructions are verified in sequence according to the order of the change operation instructions.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the database changing method described in any one of claims 1 to 7 are implemented.

9. An electronic device, characterized in that: include: a memory having a computer program stored thereon; A processor, configured to execute the computer program in the memory to implement the steps of the database change method according to any one of claims 1 to 7.

10. A computer program product, characterized in that The invention comprises a computer program, which, when executed by a processor, implements the steps of the database changing method according to any one of claims 1 to 7.