CN115994189A - Structure synchronization method, device, equipment and medium for multi-environment database - Google Patents

Structure synchronization method, device, equipment and medium for multi-environment database Download PDF

Info

Publication number
CN115994189A
CN115994189A CN202310158501.1A CN202310158501A CN115994189A CN 115994189 A CN115994189 A CN 115994189A CN 202310158501 A CN202310158501 A CN 202310158501A CN 115994189 A CN115994189 A CN 115994189A
Authority
CN
China
Prior art keywords
environment
database
production line
target environment
database structure
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310158501.1A
Other languages
Chinese (zh)
Inventor
何广辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Pingan Payment Technology Service Co Ltd
Original Assignee
Pingan Payment Technology Service Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Pingan Payment Technology Service Co Ltd filed Critical Pingan Payment Technology Service Co Ltd
Priority to CN202310158501.1A priority Critical patent/CN115994189A/en
Publication of CN115994189A publication Critical patent/CN115994189A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application relates to the technical field of databases and digital medical treatment, and provides a structure synchronization method, device, equipment and medium of a multi-environment database, wherein the method comprises the following steps: generating a metadata routing table in response to a metadata configuration instruction, responding to a database structure synchronization instruction for a target environment, acquiring a database structure of a production line environment, a database structure of the target environment and path information of the target environment based on the metadata routing table, generating a reference structure file according to the database structure of the production line environment and caching the reference structure file to an intermediate library, comparing the difference between the database structure of the production line environment and the database structure of the target environment, generating a structure modification statement in the reference structure file according to the difference, executing the structure modification statement in the database of the target environment according to the path information of the target environment, and updating the database structure of the target environment. The method provided by the application can meet the security audit requirement and improve the operation and maintenance experience and operation and maintenance efficiency while not damaging the test data.

Description

Structure synchronization method, device, equipment and medium for multi-environment database
Technical Field
The application relates to the technical field of databases and digital medical treatment, in particular to a method, a device, equipment and a medium for synchronizing structures of multiple environment databases.
Background
With the increasing size of databases, there are often multiple database environments with different roles that coexist, including test environments, acceptance test environments, gray scale environments, development environment simulation environments, production environments, and so forth. How to ensure the structural consistency of databases in multiple environments is a problem to be solved.
In the prior art, the common solution mainly comprises environment DDL linkage release, and the structural consistency of the multi-environment database is ensured through the flow, which belongs to a soft consistency. Alternatively, the structure of each environmental database is eradicated and reconstructed, which belongs to a kind of hard consistency. However, the method of removing and reconstructing the structure of each environmental database makes the test data unable to be retained, and there is a problem that the corresponding object needs to be reconstructed when the line structure is pulled off line.
Therefore, the prior art lacks a structure synchronization method of the multi-environment database which can meet the security audit requirement without damaging the test data, so as to avoid the test problem of the test environment caused by the structure difference, the error report of the production line sequence caused by the environment difference and even the production line accident, thereby improving the operation and maintenance experience and the operation and maintenance efficiency.
Disclosure of Invention
In order to solve the above problems, the embodiments of the present application provide a method, an apparatus, a device, and a medium for synchronizing structures of multiple environment databases, which can meet the audit requirement of security without damaging test data, and improve the operation and maintenance experience and the operation and maintenance efficiency.
The embodiment of the application adopts the following technical scheme:
in a first aspect, a method for synchronizing structures of a multi-environment database is provided, the method comprising:
generating a metadata routing table in response to the metadata configuration instruction, wherein the metadata routing table is used for indicating the corresponding relation between the production line environment and each other environment;
responding to a database structure synchronization instruction of a target environment, and acquiring a database structure of a production line environment, a database structure of the target environment and path information of the target environment based on a metadata routing table;
generating a reference structure file according to the database structure of the production line environment, caching the reference structure file in an intermediate library, and comparing the difference between the database structure of the production line environment and the database structure of the target environment;
generating a structure modification statement in the reference structure file according to the difference;
and executing the structure modification statement in the database of the target environment according to the path information of the target environment so as to update the database structure of the target environment.
In a second aspect, there is provided a structure synchronization apparatus for a multi-environment database, the apparatus comprising:
the metadata routing table configuration unit is used for configuring a metadata routing table, wherein the metadata routing table is used for indicating the corresponding relation between the production line environment and each other environment;
the task execution unit is used for responding to a database structure synchronization instruction of the target environment and acquiring a database structure of the production line environment, a database structure of the target environment and path information of the target environment based on the metadata routing table;
the difference comparison unit is used for generating a reference structure file according to the database structure of the production line environment, caching the reference structure file in the intermediate library, and comparing the difference between the database structure of the production line environment and the database structure of the target environment;
a structure modification sentence generation unit for generating a structure modification sentence in the reference structure file according to the difference;
and the synchronization unit is used for executing the structure modification statement in the database of the target environment according to the path information of the target environment so as to update the database structure of the target environment.
In a third aspect, a computer device is provided, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor executing the computer program to perform the steps of the method for synchronizing structures of a multi-environment database as described above.
In a fourth aspect, a computer readable storage medium is provided, the computer readable storage medium storing a computer program, which when instructed by a processor, implements the steps of the method for synchronizing structures of a multi-environment database described above.
The above-mentioned at least one technical scheme that this application embodiment adopted can reach following beneficial effect:
according to the structure synchronization method of the multi-environment database, a metadata routing table is generated in response to metadata configuration instructions, and the metadata routing table is used for indicating the corresponding relation between the production line environment and each other environment; responding to a database structure synchronization instruction of a target environment, and acquiring a database structure of a production line environment, a database structure of the target environment and path information of the target environment based on a metadata routing table; generating a reference structure file according to the database structure of the production line environment, caching the reference structure file in an intermediate library, and comparing the difference between the database structure of the production line environment and the database structure of the target environment; generating a structure modification statement in the reference structure file according to the difference; and executing the structure modification statement in the database of the target environment according to the path information of the target environment so as to update the database structure of the target environment. According to the structure synchronization method of the multi-environment database, the metadata routing table is generated based on the configurable method, the corresponding relation of metadata can be automatically processed based on the configuration of developers, and the data correspondence of the production line environment and other environments can be rapidly completed through the metadata routing table; according to the multi-environment database structure synchronization method, the reference structure file is generated based on the database structure of the production line environment and is cached in the intermediate library, so that the intermediate process of pulling the database structure of the production line environment to cover the target environment is independent of the production line environment and the target environment; according to the structure synchronization method of the multi-environment database, the structure modification statement is generated and executed in the database of the target environment by comparing the database structure differences of the production line environment and the target environment, historical data is reserved, and the change action is smaller; the structure synchronization method of the multi-environment database can fully exert scale effect, meet safe audit requirements while not damaging test data, avoid test problems of test environments caused by structural differences and errors and even line accidents of production threads caused by environmental differences, and accordingly improve operation and maintenance experience and operation and maintenance efficiency.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and together with the description serve to explain the application and do not constitute an undue limitation to the application. In the drawings:
FIG. 1 is a schematic diagram of a prior art method for guaranteeing structural consistency of a multi-environment database by structural elimination reconstruction, wherein the schematic diagram includes FIG. 1a and FIG. 1b;
FIG. 2 illustrates an application environment diagram of a method of structure synchronization of a multi-environment database according to one embodiment of the present application;
FIG. 3 illustrates a flow diagram of a method of structure synchronization of a multi-environment database according to one embodiment of the present application;
FIG. 4 illustrates a flow diagram of a method of structure synchronization of a multi-environment database according to another embodiment of the present application;
FIG. 5 shows a schematic diagram of a structure synchronization device of a multi-environment database according to one embodiment of the present application;
FIG. 6 illustrates a schematic structural diagram of a computer device according to one embodiment of the present application;
fig. 7 shows a schematic structural diagram of a computer device according to another embodiment of the present application.
Detailed Description
For the purposes, technical solutions and advantages of the present application, the technical solutions of the present application will be clearly and completely described below with reference to specific embodiments of the present application and corresponding drawings. It will be apparent that the described embodiments are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
In order to enable those skilled in the art to more clearly understand the technical solutions provided by the embodiments of the present application, a method for guaranteeing structural consistency of a multi-environment database through structural elimination reconstruction in the prior art will be described first.
FIG. 1 shows a prior art schematic diagram of ensuring structural consistency of a multi-environment database by structural-cut rebuild, including FIG. 1a and FIG. 1b. As shown in fig. 1a, when the structure is changed, the process may be skipped due to failure, so that the structure of the production line environment and other environments is inconsistent. When the scale of the database is continuously increased, the probability of occurrence of structural inconsistency between other environments and the production line environment is increased exponentially, and manual repair is extremely difficult. If the structural consistency of the multi-environment database is ensured by structural elimination and reconstruction in the prior art, as shown in fig. 1b, forced pulling of the database structure coverage of the production line environment to other environments can cause failure of accumulation of test data, thereby affecting the efficiency of test work. Moreover, the industry is required to be isolated from production line environments and other environments, which results in database structures that can only be overlaid in files, and thus, there are significant drawbacks to prior art applications.
Therefore, the method for synchronizing the structure of the multi-environment database aims at the defect that the structural consistency of the multi-environment database is guaranteed, the test data can not be damaged, the safety audit requirement can be met, the problem of testing the test environment caused by structural differences, the error of the production line sequence and even the production line accident caused by the environmental differences are avoided, and the operation and maintenance experience and the operation and maintenance efficiency are improved. The following describes in detail the technical solutions provided by the embodiments of the present application with reference to the accompanying drawings.
The structure synchronization method of the multi-environment database provided by the embodiment of the application can be applied to the environment as shown in fig. 2, wherein the client side and the server side communicate through a network.
The client may be, but is not limited to, devices with a display screen and input means, such as personal computers, notebook computers, smartphones, tablet computers, and portable wearable devices. The server may be implemented by an independent server or a service platform formed by a plurality of servers. A developer can transmit metadata configuration instructions to a server through a client so that the server generates a metadata routing table based on the metadata configuration instructions, wherein the metadata routing table is used for indicating the corresponding relation between the production line environment and each other environment; a developer can transmit a database structure synchronization instruction of a target environment to a server through a client so that the server can acquire the database structure of the production line environment, the database structure of the target environment and path information of the target environment based on a metadata routing table; the server generates a reference structure file according to the database structure of the production line environment, caches the reference structure file into an intermediate library, compares the difference between the database structure of the production line environment and the database structure of the target environment, and generates a structure modification statement in the reference structure file according to the difference; and the server executes the structure modification statement in the database of the target environment according to the path information of the target environment so as to update the database structure of the target environment.
In some practical cases, when online application development is performed in the smart medical field, a large number of databases are required to store corresponding data information, and the large number of databases may belong to a plurality of environments according to different roles. The structure synchronization method based on the multi-environment database can avoid error report of production line sequence or production line accident caused by environmental difference when on-line application development in the intelligent medical field is involved, so that the operation and maintenance experience and operation and maintenance efficiency of on-line application are improved.
The present application is described in detail below by way of specific examples.
Fig. 3 is a flow chart illustrating a method for synchronizing structures of multiple environment databases according to an embodiment of the present application. As shown in fig. 3, the method includes steps S310 to S350:
in step S310, a metadata routing table is generated in response to the metadata configuration instruction, where the metadata routing table is used to indicate a correspondence between the production line environment and each other environment.
Metadata, also known as intermediate data or relay data, is an organization of data, data fields, and their relationship information. Metadata mainly describes information of data attributes to support functions such as indicating storage locations, history data, resource searching, file recording, and the like. Based on a configuration mode, metadata is configured on a client side by a developer and transmitted to a server side, so that the server side generates a metadata routing table indicating the corresponding relation between a production line environment and each other environment.
The server side can provide a front-end page for configuring metadata for the client side, and a developer inputs metadata configuration instructions through the front-end page at the client side. The metadata configuration instructions may include, but are not limited to, identification information of the production line environment and each other environment, database structures of the production line environment and each other environment, path information routed by the production line environment to each other environment, and the like. That is, the developer provides metadata information for connecting the product line environment and various other environmental data relationships to the service side by configuring metadata configuration instructions at the client side. After receiving the metadata configuration instruction, the server generates a metadata routing table according to the metadata information. The production line environment is used for indicating the synchronized database structure environment for generating the reference structure file, and each other environment is used for indicating the database structure environment which needs to be synchronized according to the database structure of the production line environment.
Step S320, in response to the database structure synchronization instruction of the target environment, the database structure of the production line environment, the database structure of the target environment and the path information of the target environment are obtained based on the metadata routing table.
The server side can provide a synchronous instruction triggering control for the client side so as to receive a database structure synchronous instruction of the developer to the target environment through the client side. At this time, the database structure synchronization instruction may be a direct operation trigger by a developer based on the development business requirement. The server side can also provide an execution frequency configuration page for the client side, so that a developer can configure the database structure synchronization period of each other environment in advance at the client side. At this time, when the monitoring time of the server reaches the database structure synchronization period of the target environment, a database structure synchronization instruction of the target environment is triggered. The server side can acquire the database structure of the product line environment, the database structure of the target environment and the path information of the target environment based on the metadata routing table. The target environment is used to indicate the database structure environment among the other environments that is designated to perform the database structure synchronization task.
Step S330, generating a reference structure file according to the database structure of the production line environment, caching the reference structure file in the intermediate library, and comparing the difference between the database structure of the production line environment and the database structure of the target environment.
The server may, but is not limited to, form a reference structure file format for the database structure of the production line environment into the intermediate repository through svn file service. The intermediate library is a database for caching the reference structure file by a user, and the intermediate process of pulling the database structure of the production line environment to cover the target environment is independent of the production line environment and the target environment by caching the reference structure file in the intermediate library. The server has obtained the database structure of the production line environment and the database structure of the target environment through the metadata routing table, so the server can compare the differences of the database structures of the production line environment and the database structures of the target environment by, but not limited to, traversing header information and the like included in the database structures of the production line environment and the target environment. The server may also determine, based on the link logs of the production line environment and the target environment, whether a structural difference exists between the database structure of the production line environment and the database structure of the target environment during execution.
Step S340, generating a structure modification statement in the reference structure file according to the difference.
When the server side has differences in comparison with the database structure of the production line environment and the database structure of the target environment, generating a structure modification statement in the reference structure file cached in the intermediate library according to the differences. The structure-modifying statement may be, but is not limited to, an SQL statement that indicates a difference between a database structure of the production line environment and a database structure of the target environment.
Step S350, executing the structure modification statement in the database of the target environment according to the path information of the target environment so as to update the database structure of the target environment.
Based on the path information of the target environment, the server side routes the structure modification statement cached in the intermediate library to the database of the target environment for execution, so that the database structure of the production line environment is synchronized to the target environment.
As can be seen from the method shown in fig. 3, the structure synchronization method of the multi-environment database provided by the present application generates a metadata routing table in response to a metadata configuration instruction, where the metadata routing table is used to indicate a correspondence between a product line environment and each other environment; responding to a database structure synchronization instruction of a target environment, and acquiring a database structure of a production line environment, a database structure of the target environment and path information of the target environment based on a metadata routing table; generating a reference structure file according to the database structure of the production line environment, caching the reference structure file in an intermediate library, and comparing the difference between the database structure of the production line environment and the database structure of the target environment; generating a structure modification statement in the reference structure file according to the difference; and executing the structure modification statement in the database of the target environment according to the path information of the target environment so as to update the database structure of the target environment. According to the structure synchronization method of the multi-environment database, the metadata routing table is generated based on the configurable method, the corresponding relation of metadata can be automatically processed based on the configuration of developers, and the data correspondence of the production line environment and other environments can be rapidly completed through the metadata routing table; according to the multi-environment database structure synchronization method, the reference structure file is generated based on the database structure of the production line environment and is cached in the intermediate library, so that the intermediate process of pulling the database structure of the production line environment to cover the target environment is independent of the production line environment and the target environment; according to the structure synchronization method of the multi-environment database, the structure modification statement is generated and executed in the database of the target environment by comparing the database structure differences of the production line environment and the target environment, historical data is reserved, and the change action is smaller; the structure synchronization method of the multi-environment database can fully exert scale effect, meet safe audit requirements while not damaging test data, avoid test problems of test environments caused by structural differences and errors and even line accidents of production threads caused by environmental differences, and accordingly improve operation and maintenance experience and operation and maintenance efficiency.
In some optional embodiments, in the above method, step S310 generates a metadata routing table in response to the metadata configuration instruction, where the metadata routing table is used to indicate a correspondence between the product line environment and each other environment, and includes: providing a front-end page, and receiving a metadata configuration instruction through the front-end page; acquiring metadata information of the production line environment and each other environment based on the metadata configuration instruction, wherein the metadata information comprises a database structure and path information; and generating a metadata routing table according to the metadata information.
The server side provides the front-end page to the client side. The developer inputs metadata configuration instructions on a front-end page of the client. After receiving the metadata configuration instruction, the server side can acquire metadata information of the production line environment and various other environments provided by the developer based on the metadata configuration instruction. In order to synchronize the database structures of the production line environment and each other environment, the metadata information includes at least a database structure and path information. That is, the metadata information includes at least data that can be used to indicate a database structure of the line environment and each other environment and data that is used to indicate path information routed from the line environment to each other environment. And the server generates a metadata routing table according to the metadata information. Based on the pre-configured metadata routing table, when the server starts to execute the synchronization task of the database structure, the server can automatically process the corresponding relation of the metadata, and the database structure correspondence of the production line environment and the target environment is rapidly completed through the metadata routing table, so that the operation and maintenance efficiency is greatly improved.
In some optional embodiments, in the above method, step S320, in response to a database structure synchronization instruction for the target environment, obtains the database structure of the production line environment, the database structure of the target environment, and path information of the target environment based on the metadata routing table, including: providing a synchronous instruction triggering control, and receiving a database structure synchronous instruction of a target environment through the synchronous instruction triggering control; and searching the database structure of the production line environment, the database structure of the target environment and the path information of the target environment in the metadata routing table according to the database structure synchronization instruction.
The server side can provide a synchronous instruction triggering control for the client side, wherein the control can comprise an production line environment configuration control, a target environment configuration control, a task execution selection control and the like; the controls may also include user information configuration controls, and the like. The developer can configure the structure synchronization task from the database of which production line environment (or which user) to the database of which target environment in the synchronization instruction trigger control of the client. And the developer can execute the selection result of the selection control through the task and send a database structure synchronization instruction for the target environment to the server. After receiving the database structure synchronization instruction, the server can search the database structure of the required production line environment, the database structure of the target environment and the path information of the target environment from the metadata routing table based on the structure synchronization task issued by the developer.
In some optional embodiments, in the above method, step S330 generates a reference structure file according to a database structure of the production line environment and caches the reference structure file in the intermediate library, and compares a difference between the database structure of the production line environment and a database structure of the target environment, including: exporting a database structure of the production line environment, and generating a reference structure file to be cached in an intermediate library; and comparing the link logs of the production line environment with the link logs of the target environment, and determining the difference item of the database structure of the production line environment and the database structure of the target environment.
The server may start comparing database structure differences between the production line environment and other environments by executing the pre-check. The server side can firstly export the database structure of the production line environment through the svn file service to form a reference structure file format and then fill the reference structure file format into the intermediate library. The server then looks at the link logs of the production line environment and the target environment. The purpose of checking the link log is to confirm that the whole task is free from problems on the line again, and meanwhile, whether the database structures at two sides of the production line environment and the target environment have structural differences or not can be checked when the database structures are executed. That is, under the technical scheme of the application, the server side can acquire the database structure of the production line environment and the database structure of the target environment through the metadata routing table, and then traverse based on basic level information such as the table header and the like to determine whether a difference item exists between the database structure of the production line environment and the database structure of the target environment; the server side can also pull the link logs of the production line environment and the target environment after starting to execute the structure synchronization task, and compare whether the database structure of the production line environment and the database structure of the target environment have difference items according to the link logs.
In some alternative embodiments, in the above method, step S340 generates a structure modification statement in the reference structure file according to the difference, including: and generating SQL sentences for describing the differences between the database structures of the production line environment and the database structures of the target environment in the reference structure file according to the differences.
The server determines a difference item between the database structures of the production line environment and the target environment according to the difference of the database structures of the comparison production line environment and the database structures of the target environment, and generates a structure modification statement in a reference file cached in the intermediate library according to the difference item. SQL is a database query and programming language used to access data and query, update, and manage relational database systems. The server side can automatically generate SQL sentences describing the difference items according to the database structure difference items of the production line environment and the target environment, and package the structure modification sentences into files.
In some optional embodiments, in the above method, step S350, executing the structure modification statement in the database of the target environment according to the path information of the target environment to update the database structure of the target environment includes: and executing SQL sentences in the database of the target environment according to the path information of the target environment so as to synchronize the database structure of the production line environment to the target environment.
And the server side routes the structure modification statement cached in the intermediate library to the database of the target environment for execution according to the path information of the target environment. In particular, when the structure-modifying statement is an SQL statement describing a difference between a database structure of the production line environment and a database structure of the target environment, the SQL statement is executed in the database of the target environment, thereby synchronizing the database structure of the production line environment to the target environment. The server side can also route the reference structure file to the target environment together, so that after the database structure synchronization is performed by the database execution structure modification statement of the target environment, the updated database structure of the target environment is compared with the database structure of the reference structure file to verify the synchronization result.
In some optional embodiments, in the above method, step S310 generates a metadata routing table in response to the metadata configuration instruction, where after the step of the metadata routing table is used to indicate a correspondence between the production line environment and each other environment, step S330 generates a reference structure file according to a database structure of the production line environment and caches the reference structure file in the intermediate repository, and compares a difference between the database structure of the production line environment and a database structure of the target environment, the method further includes: providing an execution frequency configuration page, and receiving the synchronization period of each other environment through the execution frequency configuration page; and monitoring time, and acquiring a database structure of the production line environment, a database structure of the target environment and path information of the target environment based on the metadata routing table when the time falls into a synchronous period of the target environment.
In addition to the structure synchronization task triggered by direct manipulation by the developer based on the development business requirements, the server may also provide an execution frequency configuration page to the client, so that the developer configures the database structure synchronization period of each other environment in advance based on the configuration page. For example, the developer may configure the period of performing the database structure synchronization from the production line environment to the simulation environment to be 1 hour once, for example, the developer may configure the period of performing the database structure synchronization from the production line environment to the test environment to be 1 day once, and so on. The execution frequency can be determined according to different environment attributes and different requirements. The execution frequency can be accurate to the minute level, but the higher the execution frequency, the more resources are consumed, so that the execution frequency can preferably meet the demand of the research and development business in the hour level.
And the server monitors the time after receiving the synchronization period of each other environment through the execution frequency configuration page. And when the time falls into the synchronous period of any one of the other environments, acquiring the database structure of the production line environment, the database structure of the target environment and the path information of the target environment based on the metadata routing table. That is, in this embodiment, the server may perform multiple database structure synchronization tasks simultaneously. That is, for example, the period of executing the database structure synchronization from the production line environment to the simulation environment configured by the developer is once 1 hour, the period of executing the database structure synchronization from the production line environment to the test environment configured by the developer is once 1 day, and when the time falls into the period of executing the database structure synchronization from the production line environment to the simulation environment and simultaneously falls into the period of executing the database structure synchronization from the production line environment to the simulation environment, the server starts executing two structure synchronization tasks at the same time, and the two structure synchronization tasks do not interfere with each other.
Fig. 4 is a flow chart of a method for synchronizing structures of a multi-environment database according to another embodiment of the present application. According to the illustration of fig. 4, the method may comprise the steps of:
in step S401, a front-end page is provided, and a metadata configuration instruction is received through the front-end page.
In step S402, metadata information of the product line environment and each other environment is obtained based on the metadata configuration instruction, wherein the metadata information includes database structure and path information.
Step S403, generating a metadata routing table according to the metadata information, where the metadata routing table is used to indicate a correspondence between the production line environment and each other environment.
Step S404, providing a synchronous instruction triggering control, receiving a database structure synchronous instruction of the target environment through the synchronous instruction triggering control, and searching a database structure of the production line environment, a database structure of the target environment and path information of the target environment in a metadata routing table according to the database structure synchronous instruction.
Or, in step S405, an execution frequency configuration page is provided, and the execution frequency configuration page is used to receive the synchronization period of each other environment, monitor the time, and search the database structure of the production line environment, the database structure of the target environment and the path information of the target environment in the metadata routing table when the time falls into the synchronization period of the target environment.
Step S406, a database structure of the production line environment is exported, and a reference structure file is generated and cached in the intermediate library.
Step S407, comparing the link logs of the production line environment and the target environment, and determining the difference item of the database structure of the production line environment and the database structure of the target environment.
Step S408, a SQL statement for describing the difference between the database structure of the production line environment and the database structure of the target environment is generated in the reference structure file according to the difference.
Step S409, executing SQL sentences in the database of the target environment according to the path information of the target environment to synchronize the database structure of the production line environment to the target environment.
Fig. 5 shows a schematic structural diagram of a structural synchronization device of the multi-environment database according to an embodiment of the present application. As shown in fig. 5, the apparatus 500 includes:
a metadata routing table configuration unit 501, configured to generate a metadata routing table in response to a metadata configuration instruction, where the metadata routing table is used to indicate a correspondence between an environment of a production line and each other environment;
the task execution unit 502 is configured to obtain, based on the metadata routing table, a database structure of the production line environment, a database structure of the target environment, and path information of the target environment in response to a database structure synchronization instruction for the target environment;
The difference comparing unit 503 is configured to generate a reference structure file according to the database structure of the production line environment, cache the reference structure file in the intermediate library, and compare the difference between the database structure of the production line environment and the database structure of the target environment;
a structure modification sentence generation unit 504 for generating a structure modification sentence in the reference structure file according to the difference;
a synchronization unit 505, configured to execute a structure modification statement in the database of the target environment according to the path information of the target environment, so as to update the database structure of the target environment.
In some optional embodiments, in the above apparatus 500, the metadata routing table configuration unit 501 is specifically configured to: providing a front-end page, and receiving a metadata configuration instruction through the front-end page; acquiring metadata information of the production line environment and each other environment based on the metadata configuration instruction, wherein the metadata information comprises a database structure and path information; and generating a metadata routing table according to the metadata information.
In some alternative embodiments, in the above-mentioned apparatus 500, the task execution unit 502 is specifically configured to: providing a synchronous instruction triggering control, and receiving a database structure synchronous instruction of a target environment through the synchronous instruction triggering control; and searching the database structure of the production line environment, the database structure of the target environment and the path information of the target environment in the metadata routing table according to the database structure synchronization instruction.
In some alternative embodiments, in the above-mentioned apparatus 500, the difference comparing unit 503 is specifically configured to: exporting a database structure of the production line environment, and generating a reference structure file to be cached in an intermediate library; and comparing the link logs of the production line environment with the link logs of the target environment, and determining the difference item of the database structure of the production line environment and the database structure of the target environment.
In some optional embodiments, in the above apparatus 500, the structure modification sentence generating unit 504 is further specifically configured to: and generating SQL sentences for describing the differences between the database structures of the production line environment and the database structures of the target environment in the reference structure file according to the differences.
In some alternative embodiments, in the above-mentioned apparatus 500, the synchronization unit 505 is further specifically configured to: and executing SQL sentences in the database of the target environment according to the path information of the target environment so as to synchronize the database structure of the production line environment to the target environment.
In some optional embodiments, the apparatus 500 further includes an automatic task monitoring unit, specifically configured to: providing an execution frequency configuration page, and receiving the synchronization period of each other environment through the execution frequency configuration page; and monitoring time, and acquiring a database structure of the production line environment, a database structure of the target environment and path information of the target environment based on the metadata routing table when the time falls into a synchronous period of the target environment.
It should be noted that, the structure synchronization device 500 of the multi-environment database can implement the structure synchronization method of the multi-environment database one by one, which is not described herein.
Fig. 6 shows a schematic structural diagram of a computer device according to an embodiment of the present application, which according to fig. 6 comprises a processor, a memory, a network interface and a database connected via a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes non-volatile and/or volatile storage media and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface of the computer device is for communicating with an external client via a network connection. The computer program, when executed by a processor, performs the functions or steps of the server side of the method for synchronizing structures in a multi-environment database.
In one embodiment, the computer device provided in the present application includes a memory and a processor, the memory storing a database and a computer program executable on the processor, the processor executing the computer program to perform the steps of:
Generating a metadata routing table in response to the metadata configuration instruction, wherein the metadata routing table is used for indicating the corresponding relation between the production line environment and each other environment;
responding to a database structure synchronization instruction of a target environment, and acquiring a database structure of a production line environment, a database structure of the target environment and path information of the target environment based on a metadata routing table;
generating a reference structure file according to the database structure of the production line environment, caching the reference structure file in an intermediate library, and comparing the difference between the database structure of the production line environment and the database structure of the target environment;
generating a structure modification statement in the reference structure file according to the difference;
and executing the structure modification statement in the database of the target environment according to the path information of the target environment so as to update the database structure of the target environment.
The method executed by the structure synchronization device of the multi-environment database disclosed in the embodiment shown in fig. 5 of the present application may be applied to a processor or implemented by the processor. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or by instructions in the form of software. The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The steps of a method disclosed in connection with the embodiments of the present application may be embodied directly in hardware, in a decoded processor, or in a combination of hardware and software modules in a decoded processor. The software modules may be located in a random access memory, flash memory, read only memory, programmable read only memory, or electrically erasable programmable memory, registers, etc. as well known in the art. The storage medium is located in a memory, and the processor reads the information in the memory and, in combination with its hardware, performs the steps of the above method.
In one embodiment, a computer device is also provided, which may be a client, as shown in FIG. 7. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface of the computer device is for communicating with an external server via a network connection. The computer program, when executed by a processor, performs the functions or steps of the client side of the structure synchronization method for a multi-environment database.
In one embodiment, there is also provided a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
generating a metadata routing table in response to the metadata configuration instruction, wherein the metadata routing table is used for indicating the corresponding relation between the production line environment and each other environment;
Responding to a database structure synchronization instruction of a target environment, and acquiring a database structure of a production line environment, a database structure of the target environment and path information of the target environment based on a metadata routing table;
generating a reference structure file according to the database structure of the production line environment, caching the reference structure file in an intermediate library, and comparing the difference between the database structure of the production line environment and the database structure of the target environment;
generating a structure modification statement in the reference structure file according to the difference;
and executing the structure modification statement in the database of the target environment according to the path information of the target environment so as to update the database structure of the target environment.
It should be noted that, the functions or steps that can be implemented by the computer device or the computer readable storage medium may correspond to the relevant descriptions in the foregoing method embodiments, and are not described herein for avoiding repetition.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the various embodiments provided herein may include non-volatile and/or volatile memory. The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), memory bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions.
The above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention, and are intended to be included in the scope of the present invention.

Claims (10)

1. A method for synchronizing structures of a multi-environment database, the method comprising:
generating a metadata routing table in response to a metadata configuration instruction, wherein the metadata routing table is used for indicating the corresponding relation between the production line environment and each other environment;
Responding to a database structure synchronization instruction of a target environment, and acquiring a database structure of the production line environment, the database structure of the target environment and path information of the target environment based on the metadata routing table;
generating a reference structure file according to the database structure of the production line environment, caching the reference structure file in an intermediate library, and comparing the difference between the database structure of the production line environment and the database structure of the target environment;
generating a structure modification statement in the reference structure file according to the difference;
and executing the structure modification statement in the database of the target environment according to the path information of the target environment so as to update the database structure of the target environment.
2. The method for synchronizing structures of multiple environment databases according to claim 1, wherein the generating a metadata routing table in response to a metadata configuration instruction, wherein the metadata routing table is configured to indicate correspondence between an environment of a production line and each other environment, comprises:
providing a front-end page, and receiving a metadata configuration instruction through the front-end page;
acquiring metadata information of the production line environment and each other environment based on the metadata configuration instruction, wherein the metadata information comprises a database structure and path information;
And generating a metadata routing table according to the metadata information.
3. The method for synchronizing the structure of the multi-environment database according to claim 1, wherein the obtaining the database structure of the production line environment, the database structure of the target environment, and the path information of the target environment based on the metadata routing table in response to the database structure synchronization instruction for the target environment comprises:
providing a synchronous instruction triggering control, and receiving a database structure synchronous instruction of a target environment through the synchronous instruction triggering control;
and searching the database structure of the production line environment, the database structure of the target environment and the path information of the target environment in the metadata routing table according to the database structure synchronization instruction.
4. The method for synchronizing the structure of the multi-environment database according to claim 1, wherein generating the reference structure file according to the database structure of the production line environment and caching the reference structure file in the intermediate library, and comparing the difference between the database structure of the production line environment and the database structure of the target environment, comprises:
exporting a database structure of the production line environment, and generating a reference structure file to be cached in an intermediate library;
And comparing the link logs of the production line environment and the target environment, and determining a difference item of a database structure of the production line environment and a database structure of the target environment.
5. The method of claim 1, wherein generating a structure modification statement in the reference structure file based on the differences comprises:
and generating SQL sentences for describing the differences between the database structure of the production line environment and the database structure of the target environment in the reference structure file according to the differences.
6. The method for synchronizing structures of multiple environment databases according to claim 5, wherein said executing the structure modification statement in the database of the target environment based on the path information of the target environment to update the database structure of the target environment comprises:
and executing the SQL sentence in the database of the target environment according to the path information of the target environment so as to synchronize the database structure of the production line environment to the target environment.
7. The method of claim 1, wherein the generating a metadata routing table in response to a metadata configuration instruction, wherein the metadata routing table is configured to indicate correspondence between a production line environment and each other environment, and wherein the generating a reference structure file from the database structure of the production line environment and buffering the reference structure file to an intermediate repository, and comparing differences between the database structure of the production line environment and the database structure of the target environment, is further performed before the step of:
Providing an execution frequency configuration page, and receiving the synchronization period of each other environment through the execution frequency configuration page;
and monitoring time, and acquiring a database structure of the production line environment, the database structure of the target environment and path information of the target environment based on the metadata routing table when the time falls into a synchronous period of the target environment.
8. A structure synchronization device for a multi-environment database, the device comprising:
the metadata routing table configuration unit is used for configuring a metadata routing table, wherein the metadata routing table is used for indicating the corresponding relation between the production line environment and each other environment;
the task execution unit is used for responding to a database structure synchronization instruction of a target environment and acquiring a database structure of the production line environment, a database structure of the target environment and path information of the target environment based on the metadata routing table;
the difference comparison unit is used for generating a reference structure file according to the database structure of the production line environment, caching the reference structure file in an intermediate library and comparing the difference between the database structure of the production line environment and the database structure of the target environment;
A structure modification sentence generating unit, configured to generate a structure modification sentence in the reference structure file according to the difference;
and the synchronization unit is used for executing the structure modification statement in the database of the target environment according to the path information of the target environment so as to update the database structure of the target environment.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method for structure synchronisation of a multi-environment database according to any of claims 1 to 7 when the computer program is executed.
10. A computer readable storage medium storing a computer program, characterized in that the computer program when instructed by a processor implements the steps of the method for structure synchronization of a multi-environment database according to any one of claims 1 to 7.
CN202310158501.1A 2023-02-16 2023-02-16 Structure synchronization method, device, equipment and medium for multi-environment database Pending CN115994189A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310158501.1A CN115994189A (en) 2023-02-16 2023-02-16 Structure synchronization method, device, equipment and medium for multi-environment database

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310158501.1A CN115994189A (en) 2023-02-16 2023-02-16 Structure synchronization method, device, equipment and medium for multi-environment database

Publications (1)

Publication Number Publication Date
CN115994189A true CN115994189A (en) 2023-04-21

Family

ID=85995166

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310158501.1A Pending CN115994189A (en) 2023-02-16 2023-02-16 Structure synchronization method, device, equipment and medium for multi-environment database

Country Status (1)

Country Link
CN (1) CN115994189A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117149911A (en) * 2023-09-12 2023-12-01 易方达基金管理有限公司 Regression parameter synchronization method and device for simulation test environment

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117149911A (en) * 2023-09-12 2023-12-01 易方达基金管理有限公司 Regression parameter synchronization method and device for simulation test environment
CN117149911B (en) * 2023-09-12 2024-03-15 易方达基金管理有限公司 Regression parameter synchronization method and device for simulation test environment

Similar Documents

Publication Publication Date Title
CN110069572B (en) HIVE task scheduling method, device, equipment and storage medium based on big data platform
WO2020119434A1 (en) Method and apparatus for interface data processing, method and apparatus for automated testing, device, and medium
CN109302522B (en) Test method, test device, computer system, and computer medium
JP6452629B2 (en) Parallel execution of continuous event processing (CEP) queries
US8745641B1 (en) Automatic verification and anomaly detection in a representational state transfer (REST) application programming interface
CN110704297B (en) Code review method, device, computer equipment and storage medium
CN111078659B (en) Model updating method, device, computer readable storage medium and computer equipment
CN107391634B (en) Data migration method and device
CN110764998B (en) Data comparison method, device, equipment and storage medium based on Django framework
CN113094430B (en) Data processing method, device, equipment and storage medium
CN113238924B (en) Chaotic engineering realization method and system in distributed graph database system
CN110162334B (en) Code management method, device and storage medium
CN112559525B (en) Data checking system, method, device and server
CN115994189A (en) Structure synchronization method, device, equipment and medium for multi-environment database
CN113360581A (en) Data processing method, device and storage medium
CN110750443A (en) Webpage testing method and device, computer equipment and storage medium
CN111339118A (en) Kubernetes-based resource change history recording method and device
US11163673B1 (en) Enhanced testing by automated reuse of test metrics
US11221862B2 (en) Capturing data from a live web application to populate a demo application
US11893382B2 (en) Prepopulated container images repositories for CI/CD environments
CN112379913B (en) Software optimization method, device, equipment and storage medium based on risk identification
CN116755699A (en) Compiling processing method, compiling processing device, electronic equipment and storage medium
CN115827922A (en) Visual analysis processing method and system based on wind power data and computer equipment
CN112765188B (en) Configuration information processing method, configuration management system, electronic device and storage medium
CN114791900A (en) Operator-based Redis operation and maintenance method, device, system and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination