Method, device, equipment and computer storage medium for data migration
By generating migration templates and importing them into the target database, the problem of data migration between business systems with inconsistent data specifications was solved, achieving an efficient and flexible data migration process and ensuring data integrity and business logic.
Patent Information
- Application Number
- CN202211557662.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-06
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2042-12-06
AI Technical Summary
Existing technologies cannot support data migration between business systems with inconsistent data specifications, making it impossible to migrate data between these systems.
By acquiring the target database and preset data structure, a migration template is generated. The target migration template is matched with the data structure of the initial database, and the data information is imported into the target database to realize data migration between business systems with different data specifications.
It enables data migration between business systems with different data specifications, improving migration quality and flexibility, and ensuring data integrity and business logic.
Smart Images

Figure CN116303337B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the field of data migration, and particularly relates to a data migration method, device, equipment and computer storage medium. BACKGROUND
[0002] With the rapid development of information technology, after a period of use, business systems will usually be replaced by new business systems due to technical updates or business changes. However, the existing data migration platform requires that the old business system and the new business system are consistent in data specification requirements, which leads to the fact that the business systems with inconsistent data specifications cannot perform data migration.
[0003] The technical problem that the existing technology does not support data migration between business systems with inconsistent data specifications, resulting in the fact that the business systems with inconsistent data specifications cannot perform data migration has not been solved. SUMMARY
[0004] The embodiments of the present application provide a data migration method, device, equipment and computer storage medium, which can solve the technical problem that the existing technology does not support data migration between business systems with inconsistent data specifications, resulting in the fact that the business systems with inconsistent data specifications cannot perform data migration.
[0005] In one aspect, the embodiments of the present application provide a data migration method, which comprises: obtaining a data structure of a target database and a plurality of preset data structures, wherein the preset data structure is the data structure of the database; generating a plurality of migration templates according to the data structure of the target database and the plurality of preset data structures, wherein the migration template corresponds to the preset data structure one by one, and the migration template is used to indicate the correspondence between the preset data structure and the data structure of the target database; obtaining a data structure of an initial database; determining a target migration template matched with the initial database according to the data structure of the initial database and the preset data structure corresponding to the plurality of migration templates, wherein the data structure of the initial database is the same as the preset data structure corresponding to the target migration template; and importing data information in the initial database into the target database according to the target migration template.
[0006] In another aspect, an embodiment of the present application provides a data migration device. The device comprises: a first obtaining unit configured to obtain a data structure of a target database and a plurality of preset data structures, wherein the preset data structures are data structures of databases; a generating unit configured to generate a plurality of migration templates according to the data structure of the target database and the plurality of preset data structures, wherein the migration templates correspond to the preset data structures one by one, and the migration templates are used to indicate a corresponding relationship between the preset data structures and the data structure of the target database; a second obtaining unit configured to obtain a data structure of an initial database; a determining unit configured to determine a target migration template matched with the initial database according to the data structure of the initial database and preset data structures corresponding to the migration templates, wherein the data structure of the initial database is the same as the preset data structure corresponding to the target migration template; and an importing unit configured to import data information in the initial database into the target database according to the target migration template.
[0007] In another aspect, an embodiment of the present application provides a data migration device. The device comprises: a processor and a memory storing computer program instructions; and the processor executes the computer program instructions to implement the above data migration method.
[0008] In another aspect, an embodiment of the present application provides a computer storage medium. The computer storage medium stores computer program instructions. When the computer program instructions are executed by a processor, the data migration method is implemented.
[0009] The data migration method, device, equipment and computer storage medium provided by the embodiments of the present application can customize migration templates (migration specifications) for a target database according to different preset data structures, and then the corresponding migration templates (migration specifications) can be found for different initial databases according to their data structures, and then the data information of the initial databases can be migrated into the target database based on the corresponding migration templates (migration specifications), thereby solving the technical problem that the prior art can only migrate data for business systems with consistent data specifications, and cannot migrate data for business systems with inconsistent data specifications, and thereby realizing data migration between business systems with inconsistent data specifications. BRIEF DESCRIPTION OF DRAWINGS
[0010] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed in the embodiments of the present application will be briefly introduced. Those skilled in the art can obtain other drawings according to these drawings without creating any creative labor.
[0011] Figure 1 is a flowchart of a data migration method provided by an embodiment of the present application Figure 1 ;
[0012] Figure 2 is a flowchart of a method of data migration provided by an embodiment of the present application Figure 2 ;
[0013] Figure 3 is a structural diagram of an apparatus of data migration provided by an embodiment of the present application Figure 1 ;
[0014] Figure 4 is a structural diagram of an apparatus of data migration provided by an embodiment of the present application Figure 2 ;
[0015] Figure 5 is a structural diagram of an apparatus of data migration provided by an embodiment of the present application DETAILED DESCRIPTION
[0016] The features and exemplary embodiments of the various aspects of the present application will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are merely intended to explain the present application, and are not intended to limit the present application. The present application can be implemented without some of the specific details described below. The following description of the embodiments is merely intended to provide a better understanding of the present application through showing examples of the present application.
[0017] It should be noted that, in this document, the terms such as first and second are merely used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the terms "include", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such a process, method, article or device. Without more limitations, the elements defined by the statement "include" do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0018] To solve the problems in the prior art, the embodiments of the present application provide a method, apparatus, device and computer storage medium for data migration. First, the method for data migration provided by the embodiments of the present application is introduced.
[0019] Figure 1 A flowchart of a method of data migration provided by an embodiment of the present application is shown.
[0020] As Figure 1As shown, the data migration method comprises the following steps:
[0021] S101, obtaining a data structure of a target database and a plurality of preset data structures, wherein the preset data structures are data structures of databases.
[0022] The target database can be a database of any micro-service application system in a new business system adopting a "micro-service + containerization" architecture mode.
[0023] S102, generating a plurality of migration templates according to the data structure of the target database and the plurality of preset data structures, wherein the migration templates correspond one-to-one to the preset data structures, and the migration templates are used to indicate the correspondence between the preset data structures and the data structure of the target database;
[0024] The migration templates used to indicate the correspondence between the preset data structures and the data structure of the target database can refer to the mapping relationship and format conversion relationship between each data element in the preset data structure and each data element in the data structure of the target database.
[0025] S103, obtaining a data structure of an initial database;
[0026] S104, determining a target migration template matched with the initial database according to the data structure of the initial database and the preset data structures corresponding to the plurality of migration templates, wherein the data structure of the initial database is the same as the preset data structure corresponding to the target migration template;
[0027] S105, importing data information in the initial database into the target database according to the target migration template.
[0028] In the case of multiple initial databases, in S104, a corresponding target migration template is matched for each initial database in turn, and in S105, data information in the initial database is imported into the target database according to the target migration template matched with the initial database.
[0029] The embodiments of the present application customize migration templates (migration specifications) for the target database according to different preset data structures, and then realize that different initial databases can find their corresponding migration templates (migration specifications) according to their data structures, and then migrate their data information into the target database based on their corresponding migration templates (migration specifications), thereby solving the technical problem that the prior art can only perform data migration on business systems with consistent data specifications, and cannot perform data migration on business systems with inconsistent data specifications.
[0030] When the old business system is upgraded to the new business system, and the new business system adopts the "micro-service + containerization" architecture mode, the data migration method provided in the embodiments of the present application can be sequentially performed on the database of each micro-service application system in the new business system, so as to migrate the data information in the old business system to the new business system.
[0031] It should be further pointed out that when the data migration method provided in the embodiments of the present application is sequentially performed on the database of each micro-service application system in the new business system, the migration template generated by the database of each micro-service application system further includes the data dependency relationship between the databases of each micro-service application system.
[0032] It should be further pointed out that when the old business system is upgraded to the new business system, and the old business system involves multiple databases, the steps of obtaining the data structure of the initial database, determining the target migration template matched with the initial database according to the data structure of the initial database and the preset data structure corresponding to the multiple migration templates, and importing the data information in the initial database into the target database according to the target migration template can be sequentially performed on each database of the old business system, so as to migrate the data information in the multiple databases of the old business system to the new business system. The initial database can be one or multiple.
[0033] When the data structure of the target database is upgraded and adjusted, the migration template of the target database can be synchronously adjusted to realize dynamic adjustment of the migration specification, so that the data migration method provided in the embodiments of the present application has higher flexibility.
[0034] In one embodiment, importing the data information in the initial database into the target database according to the target migration template can be realized by the following steps:
[0035] S1051, constructing the database table corresponding to the target database according to the data structure of the target database.
[0036] S1052, importing the data information in the initial database into the database table according to the target migration template corresponding to the initial database.
[0037] S1053, importing the data information in the database table into the corresponding target database.
[0038] The embodiment of the present application constructs a database table corresponding to the target database between the initial database and the target database, so that the data information in the initial database which needs to be migrated to the target database can be integrated in the database table outside the target database, so that the migration database can be checked / data supplemented / data adjusted before the data information in the initial database is migrated to the target database, thereby improving the migration quality.
[0039] In one embodiment, according to the data structure of the target database, the database table corresponding to the target database can be constructed by the following implementation:
[0040] S1051a, analyzing the data structure of the target database to obtain a data element set of the target database, wherein the data element represents a type of data in the target database;
[0041] S1051a, generating the database table corresponding to the target database according to the data element set of the target database.
[0042] The database table in the embodiment of the present application is mainly constructed based on the data element set of the target database, at this time, after the database table is filled with the data information migrated from the initial database, the target database can directly obtain the specific data information of each data element based on the database table, achieving the technical effect of efficient migration.
[0043] In one embodiment, according to the target migration template corresponding to each initial database, the data information in the plurality of initial databases can be sequentially imported into the database table by the following implementation:
[0044] S1052a, determining the attribute information of each field in the initial database according to the data structure of the initial database;
[0045] S1052b, based on the attribute information of each field in the initial database and the attribute information of each field in the target migration template, establishing the mapping relationship and conversion rule between the fields in the target migration data template and the fields in the initial database.
[0046] It should be noted that: the conversion rule can be a format conversion rule, or a content conversion rule, for example: a plurality of fields in the initial database correspond to a field in the target database after content conversion, which is not limited by the present application.
[0047] S1052c, based on the mapping relationship and conversion rule between the fields in the target migration data template and the fields in the initial database, importing the data information in the initial database into the database table.
[0048] The embodiment of the application establishes the mapping relationship and conversion rule between the fields in the target migration data template and the fields in the initial database, and imports the data information in the initial database into the database table according to the mapping relationship and conversion rule between the fields in the target migration data template and the fields in the initial database, so that the data migration between databases with different data structures and different data specifications is realized.
[0049] In one example, the importing of the data information in the initial database into the database table based on the corresponding relationship and conversion rule between the fields in the target migration data template and the fields in the initial database can be realized by the following manner: determining the target field having the corresponding relationship with the field in the target migration data template and the conversion rule of the target field in the initial database based on the corresponding relationship between the fields in the target migration data template and the fields in the initial database; performing data conversion on the target field based on the conversion rule of the target field; and importing the target field after data conversion into the database table.
[0050] In one example, the importing of the data information in the initial database into the database table based on the corresponding relationship and conversion rule between the fields in the target migration data template and the fields in the initial database can be realized by the following manner: generating an export script based on the corresponding relationship and conversion rule between the fields in the target migration data template and the fields in the initial database, importing the export script into the initial database, and executing the export script in the initial database, wherein the export script is used to determine the target field having the corresponding relationship with the field in the target migration data template in the initial database, perform data conversion on the target field, and store the target field after data conversion in the migration platform in the form of a self-defined format file, wherein the database table of the target database is established in the migration platform; at this time, the migration platform fills the data information in the self-defined format file into the database table.
[0051] It should be noted that the export script exports the target field after data conversion in the form of a self-defined format file, so that the staff can supplement the data of the self-defined format file, and the content that cannot be supplemented by the system rule can be supplemented by the staff.
[0052] In one embodiment, before the data information in the database table is imported into the target database, the method further comprises: performing business logic verification and data integrity verification on the data information in the database table; if the database table passes the verification, continuing to perform the importing of the data information in the database table into the target database.
[0053] In the embodiments of the present application, before the data information in the database table is imported into the target database, the data information in the database table is further subjected to business logic verification, thereby ensuring the data integrity and business logic of the data information in the template database after import, and ensuring the migration quality of data migration.
[0054] In one example, if the database table fails the verification, the data information in the database is adjusted according to the verification result, or the migration template is adjusted according to the verification result, and the data information is re-imported into the database table according to the adjusted migration template.
[0055] In one embodiment, importing the data information in the database table into the target database comprises:
[0056] S1053a, obtaining the data structure of the database table;
[0057] S1053b, constructing the migration script and the rollback script according to the data structure of the target database and the data structure of the database table;
[0058] S1053c, importing the migration script and the rollback script into the target database;
[0059] S1053d, executing the migration script in the target database to import the data information in the database table into the target database.
[0060] S1053e, executing the rollback script in the case of abnormal execution of the migration script to delete the data information imported by the migration script.
[0061] In the embodiments of the present application, when the data information in the database table is migrated into the target database, not only the migration script is generated, but also the corresponding rollback script is generated. At this time, if an accident occurs in the process of migrating the data information in the database table into the target database, the rollback operation of data migration can be performed to ensure the data stability of the target database.
[0062] In one embodiment, after the data information in the database table is imported into the target database, the method further comprises: judging whether the data information in the database table is successfully imported into the target database; and deleting the migration execution script and the migration rollback script in the target database after the data information in the database table is successfully imported into the target database.
[0063] In one embodiment, after the data information in the database table is imported into the target database, the method further comprises: judging whether the data information in the database table is successfully imported into the target database; and deleting the migration execution script and the migration rollback script in the target database after the data information in the database table is successfully imported into the target database.
[0064] In summary, the data migration method provided by the embodiments of the present application realizes physical isolation between the target database and the initial database by setting the database table of the target database, ensuring the data security of the target database; realizes the individualized needs of the target database on the data specification of the migration data by setting the migration template for the target database; and realizes the technical effect of smooth rollback of the migration data in the case of migration exception by setting the migration script and the rollback script.
[0065] Taking the upgrading of the old business system to the new business system and the adoption of the "micro-service + containerization" architecture mode by the new business system as an example, the data migration method provided by the above embodiments of the present application is described.
[0066] Figure 2 A flowchart of the data migration method provided by another embodiment of the present application is shown.
[0067] As shown in Figure 2 The data migration method includes the following steps:
[0068] S201: Create a data migration template according to the structure type of each micro-service database of the target system.
[0069] Since the target system is developed based on the micro-service architecture, each micro-service database in the target system is relatively independent, and thus different migration templates need to be generated for each micro-service database; meanwhile, the migration template covers the data dependency relationship between each micro-service database, so as to be applicable to the data migration of all micro-service databases in the target system.
[0070] In addition, the migration template can cover the specification requirements of the target system on the migration data when data is migrated from different source systems (source objects of data migration) to the target system. Specifically, in the actual data migration process, each source system can select a migration template according to the database structure type of the source system.
[0071] S202: Create each micro-service database table in the migration platform according to the data structure of each micro-service database of the target system. Specifically, by analyzing the structure of each micro-service database of the target system, a database structure element set is obtained, and a micro-service database table is generated according to the database structure element set, to obtain the migration platform intermediate library.
[0072] S203: Configure the mapping relationship between the migration template and the database structure of the source system. Specifically, by creating the corresponding relationship between the fields in the migration template and the fields in the database of the source system, a conversion rule is generated, and then a data migration configuration is formed, and a migration configuration task is generated.
[0073] S204: Connect the database of the source system, and export the valid data having a mapping relationship with each micro-service database from the database of the source system. Specifically, a query script generated by the migration configuration task is executed in the source database, valid data in the source database is obtained by executing the query script, data conversion is performed on the valid data, a self-defined format file is generated, and the self-defined format file is stored in a database table in the data migration platform.
[0074] S205: Perform business logic and data integrity checking on the data in the database table. Specifically, after the valid data in each source database is imported into the database table of the migration platform, the data in the database table is checked. If the checking is passed, a version number of the current data migration is obtained. If the checking fails, the migration data / migration template needs to be changed according to the error prompt information.
[0075] S206: Generate a migration-in script, which is used to import the data in the database table that passes the checking into the corresponding micro-service database, and take the version number of the data migration obtained after the database table passes the checking as the version number of the migration-in script.
[0076] S207: Based on the version number of the data migration, determine the corresponding migration-in script for the micro-service database, and execute the migration-in script in the database table of the micro-service database to complete the data migration.
[0077] S208: After the migration data is successfully imported into the micro-service database of the target system, delete the database table in the migration platform.
[0078] Figure 3 A structural schematic diagram of a data migration device provided by another embodiment of the application is shown.
[0079] As shown in Figure 3 , the data migration device comprises:
[0080] A migration template establishing unit 310 is configured to create a data migration template according to the structure type of each micro-service database of a target system.
[0081] A database table creating unit 320 is configured to create each micro-service database table in the migration platform according to the data structure of each micro-service database of the target system.
[0082] A migration task configuration unit 330 is configured to configure a mapping relationship between the migration template and the database structure of a source system. Specifically, a conversion rule is generated by establishing a corresponding relationship between the field in the migration template and the field in the database of the source system, and then a data migration configuration is formed, and a migration configuration task is generated.
[0083] The migration data collection unit 340 is configured to connect to a database of a source system, and export valid data having a mapping relationship with each micro-service database from the database of the source system. Specifically, a query script generated by performing a migration configuration task on the source database is executed, valid data in the source database is obtained by executing the query script, and the valid data is converted to generate a self-defined format file, which is stored in a database table in the data migration platform.
[0084] The migration data verification unit 350 is configured to perform business logic and data integrity verification on the data in the database table. Specifically, after the valid data in each source database is imported into the database table of the migration platform, the data in the database table is verified. If the verification is passed, a version number of the current data migration is obtained. If the verification fails, the migration data / migration template needs to be changed according to the error prompt information.
[0085] The migration script generation unit 360 is configured to generate a migration script. The migration script is used to import the data in the database table that passes the verification into a corresponding micro-service database, and the version number of the data migration obtained after the database table passes the verification is used as the version number of the migration script.
[0086] The migration data import unit 370 is configured to determine a corresponding migration script for the micro-service database based on the version number of the data migration, and execute the migration script in the database table of the micro-service database to complete the data migration.
[0087] The migration data deletion unit 380 is configured to delete the database table in the migration platform after the migration data is successfully imported into the micro-service database of the target system.
[0088] Figure 4 A structural schematic diagram of a device for data migration provided by another embodiment of the present application is shown. As shown in the figure, Figure 4 The device can include:
[0089] The first acquisition unit 410 is configured to acquire a data structure of a target database and a plurality of preset data structures, wherein the preset data structures are the data structures of the database.
[0090] The generation unit 420 is configured to generate a plurality of migration templates according to the data structure of the target database and the plurality of preset data structures, wherein the migration templates correspond one-to-one to the preset data structures, and the migration templates are used to indicate the corresponding relationship between the preset data structures and the data structure of the target database.
[0091] The second acquisition unit 430 is configured to acquire a data structure of an initial database.
[0092] The determining unit 440 is configured to determine a target migration template matched with the initial database according to a data structure of the initial database and a preset data structure corresponding to the target migration template, wherein the data structure of the initial database is the same as the preset data structure corresponding to the target migration template.
[0093] The importing unit 450 is configured to import the data information in the initial database into the target database according to the target migration template.
[0094] The embodiments of the present application customize migration templates (migration specifications) for the target database according to different preset data structures, and then realize that different initial databases can find their corresponding migration templates (migration specifications) according to their data structures, and then migrate their data information into the target database based on the corresponding migration templates (migration specifications), thereby solving the technical problem in the prior art that only the old business system and the new business system with consistent data specifications can be subjected to data migration, and the old business system and the new business system with inconsistent data specifications cannot be subjected to data migration.
[0095] In one embodiment, the importing unit 450 includes: a constructing subunit configured to construct a database table corresponding to the target database according to a data structure of the target database; a first importing subunit configured to import the data information in the initial database into the database table according to the target migration template corresponding to the initial database; and a second importing subunit configured to import the data information in the database table into the target database.
[0096] In one embodiment, the constructing subunit includes: an analyzing module configured to analyze the data structure of the target database to obtain a data element set of the target database, wherein a data element represents a type of data in the target database; and a generating module configured to generate the database table corresponding to the target database according to the data element set of the target database.
[0097] In one embodiment, the first importing subunit includes: a determining module configured to determine attribute information of each field in the initial database according to the data structure of the initial database; a first constructing module configured to establish a mapping relationship and a conversion rule between a field in the target migration data template and a field in the initial database based on the attribute information of each field in the initial database and attribute information of each field in the target migration template; and a first importing module configured to import the data information in the initial database into the database table based on the mapping relationship and the conversion rule between the field in the target migration data template and the field in the initial database.
[0098] In one embodiment, the apparatus further comprises a checking subunit configured to perform business logic checking and data integrity checking on the data information in the database table before importing the data information in the database table into the target database; and an executing subunit configured to continue to perform importing the data information in the database table into the target database if the database table passes the checking.
[0099] In one embodiment, the second importing subunit comprises an obtaining module configured to obtain a data structure of the database table; a second constructing module configured to construct a migration-in script and a rollback script according to the data structure of the target database and the data structure of the database table; a second importing module configured to import the migration-in script and the rollback script into the target database; a first executing module configured to execute the migration-in script in the target database to import the data information in the database table into the target database; and a second executing module configured to execute the rollback script to delete the data information imported by the migration-in script in the case of abnormal execution of the migration-in script.
[0100] In one embodiment, the apparatus further comprises a first judging module configured to judge whether the data information in the database table is successfully imported into the target database after importing the data information in the database table into the target database; and a first deleting unit configured to delete the migration execution script and the migration rollback script in the target database after the data information in the database table is successfully imported into the target database.
[0101] In one embodiment, the apparatus further comprises a second judging module configured to judge whether the data information in the database table is successfully imported into the target database after importing the data information in the database table into the target database; and a second deleting unit configured to delete the database table corresponding to the target database after the data information in the database table is successfully imported into the target database.
[0102] Figure 5 A hardware structure schematic diagram of the data migration apparatus provided by the embodiments of the present application is shown.
[0103] The data migration apparatus can comprise a processor 501 and a memory 502 storing computer program instructions.
[0104] Specifically, the processor 501 can comprise a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application.
[0105] The memory 502 can include mass storage for data or instructions. As an example and not by way of limitation, the memory 502 can include a hard disk drive (HDD), a floppy disk drive, flash memory, an optical disc (e.g., a compact disc (CD) or a digital versatile disc (DVD)), a solid-state drive (SSD), a USB drive, or a combination of two or more of these. Where appropriate, the memory 502 can include removable or non-removable (or fixed) media, where appropriate. The memory 502 can be internal or external to the integrated gateway disaster recovery appliance. In particular embodiments, the memory 502 is non-volatile, solid-state memory.
[0106] The memory can include read-only memory (ROM), random-access memory (RAM), magnetic disk storage mediums, optical storage mediums, flash memory devices, electrical, optical, or other physical / tangible memory storage devices. Thus, in general, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software that, when executed (by one or more processors), is operable to access the data and perform operations described with respect to the methods according to aspects of the present disclosure.
[0107] The processor 501 implements the device method of any of the data migration in the above embodiments by reading and executing computer program instructions stored in the memory 502.
[0108] In one example, the device for data migration can further include a communication interface 503 and a bus 510. Wherein, as shown in the figure, the processor 501, the memory 502, the communication interface 503 are connected through the bus 510 and complete the communication between each other. Figure 5
[0109] The communication interface 503 is mainly used to realize the communication between each module, device, unit and / or equipment in the embodiments of the present application.
[0110] Bus 510 includes a hardware, software, or both that couples components of the data migration device to each other. As an example and not by way of limitation, the bus can include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand (IB) interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or another suitable bus or a combination of two or more of these. Where appropriate, bus 510 can include one or more buses. Although this application describes and shows a particular bus, this application contemplates any suitable bus or interconnect.
[0111] In addition, the data migration device in the above embodiments can be provided in a computer storage medium. The computer storage medium stores computer program instructions; the computer program instructions are executed by a processor to implement any of the data migration methods in the above embodiments.
[0112] It is important to note that the present application is not limited to the specific configurations and processes described above and illustrated in the drawings. Detailed descriptions of known methods are omitted for the sake of brevity. In the above embodiments, several specific steps are described and shown as examples. However, the method processes of the present application are not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order of the steps, after understanding the spirit of the present application.
[0113] The functional blocks shown in the structural block diagrams described above can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a functional card, etc. When implemented in software, the elements of the present application are program or code segments used to perform the required tasks. The program or code segments can be stored in a machine-readable medium or transmitted through a data signal carried in a carrier wave over a transmission medium or communication link. The "machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. The code segments can be downloaded via a computer network such as the Internet, an intranet, etc.
[0114] It should also be noted that the example embodiments mentioned in the present application describe some methods or systems based on a series of steps or devices. However, the present application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiments, or in an order different from the embodiments, or several steps can be performed simultaneously.
[0115] The above mainly describes the aspects of the present application with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present application. It should be understood that each block in the flowcharts and / or block diagrams, and the combination of the blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus, to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing apparatus enable the implementation of the functions / actions specified in one or more blocks of the flowcharts and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field programmable logic circuit. It should also be understood that each block in the block diagrams and / or flowcharts, and the combination of the blocks in the block diagrams and / or flowcharts, can also be implemented by special hardware that performs the specified functions or actions, or can be implemented by a combination of special hardware and computer instructions.
[0116] The above is only a specific implementation of the present application, and those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described systems, modules and units can refer to the corresponding processes in the foregoing method embodiments, which will not be described here. It should be understood that the protection scope of the present application is not limited thereto, and any person skilled in the art can easily think of various equivalent modifications or replacements within the technical range disclosed in the present application, and these modifications or replacements should be covered within the protection scope of the present application.
Claims
1. A method of data migration, characterized by, The method comprises: obtaining a data structure of a target database and a plurality of preset data structures, wherein the preset data structures are data structures of databases; generating a plurality of migration templates according to the data structure of the target database and the plurality of preset data structures, wherein the migration templates correspond one-to-one to the preset data structures, and the migration templates are used to indicate the correspondence between the preset data structures and the data structure of the target database; obtaining a data structure of an initial database; determining a target migration template matched with the initial database according to the data structure of the initial database and the preset data structure corresponding to the plurality of migration templates, wherein the data structure of the initial database is the same as the preset data structure corresponding to the target migration template; directing data information in the initial database into a target database according to the target migration template; directing data information in the initial database into a target database according to the target migration template, comprising: constructing a database table corresponding to the target database according to the data structure of the target database; directing data information in the initial database into the database table according to the target migration template corresponding to the initial database; directing data information in the database table into the target database; directing data information in the database table into the target database, comprising: obtaining a data structure of the database table; constructing a migration script and a rollback script according to the data structure of the target database and the data structure of the database table; directing the migration script and the rollback script into the target database; executing the migration script in the target database to direct data information in the database table into the target database; in the case of an exception in the execution of the migration script, executing the rollback script to delete data information directed by the migration script.
2. The method of claim 1, wherein, constructing a database table corresponding to the target database according to the data structure of the target database, comprising: analyzing the data structure of the target database to obtain a data element set of the target database, wherein the data element represents a type of data in the target database; generating the database table corresponding to the target database according to the data element set of the target database.
3. The method of claim 1, wherein, directing data information in the initial database into the database table according to the target migration template corresponding to the initial database, comprising: determining attribute information of each field in the initial database according to the data structure of the initial database; establishing a mapping relationship and a conversion rule between a field in the target migration template and a field in the initial database based on the attribute information of each field in the initial database and the attribute information of each field in the target migration template; directing data information in the initial database into the database table based on the mapping relationship and the conversion rule between the field in the target migration template and the field in the initial database.
4. The method of claim 1, wherein, Before the data information in the database table is imported into the target database, the method further comprises: checking the data information in the database table according to business logic and data integrity; if the database table passes the check, the step of importing the data information in the database table into the target database is continued.
5. The method of claim 1, wherein, After the data information in the database table is imported into the target database, the method further comprises: judging whether the data information in the database table is successfully imported into the target database; after the data information in the database table is successfully imported into the target database, the migration execution script and the migration rollback script in the target database are deleted.
6. The method of claim 1, wherein, After the data information in the database table is imported into the target database, the method further comprises: judging whether the data information in the database table is successfully imported into the target database; after the data information in the database table is successfully imported into the target database, the database table corresponding to the target database is deleted.
7. An apparatus for data migration, the apparatus comprising: The device comprises: a first obtaining unit configured to obtain a data structure of a target database and a plurality of preset data structures, wherein the preset data structures are data structures of databases; a generating unit configured to generate a plurality of migration templates according to the data structure of the target database and the plurality of preset data structures, wherein the migration templates correspond one-to-one to the preset data structures, and the migration templates are used to indicate the correspondence between the preset data structures and the data structure of the target database; a second obtaining unit configured to obtain a data structure of an initial database; a determining unit configured to determine a target migration template matched with the initial database according to the data structure of the initial database and the preset data structures corresponding to the plurality of migration templates, wherein the data structure of the initial database is the same as the preset data structure corresponding to the target migration template; an importing unit configured to import data information in the initial database into a target database according to the target migration template. Importing data information in the initial database into a target database according to the target migration template comprises: constructing a database table corresponding to the target database according to the data structure of the target database; importing data information in the initial database into the database table according to the target migration template corresponding to the initial database; importing data information in the database table into the target database; Importing data information in the database table into the target database comprises: obtaining a data structure of the database table; constructing a migration script and a rollback script according to the data structure of the target database and the data structure of the database table; importing the migration script and the rollback script into the target database; executing the migration script in the target database to import data information in the database table into the target database; in the case of an exception in the execution of the migration script, executing the rollback script to delete the data information imported by the migration script.
8. An apparatus for data migration, the apparatus comprising: The device comprises a processor and a memory storing computer program instructions; The processor executes the computer program instructions to implement the data migration method according to any one of claims 1-6.
9. A computer storage medium, characterized in that, The computer storage medium stores computer program instructions, and the computer program instructions are executed by the processor to implement the data migration method according to any one of claims 1-6.
Citation Information
Patent Citations
Data migration method, system and device and computer readable storage medium
CN111241071A
Data migration method and device, computer equipment and readable storage medium
CN111367890A