Code migration method, device, equipment, storage medium, and program product

By using preset path mapping tables and database language mapping tables for code migration, the problems of low efficiency and uncontrollable quality of code migration in the existing technology are solved, and automated migration and efficient code migration processes are realized.

CN114064118BActive Publication Date: 2024-12-20CCB FINTECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111404219.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-24
Publication Date
2024-12-20
Estimated Expiration
2041-11-24

AI Technical Summary

Technical Problem

In the existing technology, code migration is inefficient, requiring rewriting code, which is time-consuming and labor-intensive, and the quality of the migration code cannot be controlled.

Method used

By obtaining preset path mapping tables and database language mapping tables, the files to be migrated are automatically migrated without rewriting code, which is simple and fast, improving the efficiency of code migration and ensuring the quality of the migration.

Benefits of technology

It realizes the automation of code migration, improves migration efficiency, simplifies the process, and ensures the quality of the code after migration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114064118B_ABST
    Figure CN114064118B_ABST
Patent Text Reader

Abstract

The present application provides a method, device, equipment, storage medium, and program product for code migration, which relate to the technical field of computer resource management, including: obtaining a preset path mapping table and a database language mapping table corresponding to the files to be migrated; the path mapping table includes a mapping relationship between a source path and a target path; according to the path mapping table, the files under the source path in the source end are migrated to the target path of the target end; according to the database language mapping table, the database configuration file migrated to the target end is converted from a language applicable to the first database to a language applicable to the second database. The solution provided by the present application utilizes the preset path mapping table and the database language mapping table corresponding to the files to be migrated to automatically migrate the code to be migrated, without the need to rewrite the code, which is simple and fast, improves the efficiency of code migration, and can ensure the quality of the migrated code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of computer resource management, and in particular to a method, apparatus, device, storage medium, and program product for code migration. Background Art

[0002] As new technologies continue to emerge, systems are also facing the pressure of continuous iteration at the technical level. In many cases, the system needs to migrate code when the business scenario remains basically unchanged.

[0003] In the prior art, traditional code migration is to rewrite and reconstruct the syntax of the database's Structured Query Language (SQL) and the system application code at the code level.

[0004] However, this method requires rewriting the code, which is time-consuming and labor-intensive, and the efficiency of code migration is very low. Summary of the invention

[0005] The present disclosure provides a method, apparatus, device, storage medium, and program product for code migration to solve the problem that the existing code migration method in the prior art needs to rewrite the code, which is time-consuming and labor-intensive, and the efficiency of code migration is very low.

[0006] According to a first aspect of the present application, a method for code migration is provided, comprising:

[0007] Acquire a preset path mapping table and a database language mapping table corresponding to the files to be migrated; the path mapping table includes a mapping relationship between a source path and a target path, and the files to be migrated are stored under the source path of the source end; the database language mapping table includes a mapping relationship between a language applicable to the first database and a language applicable to the second database;

[0008] Migrating the files under the source path in the source end to the target path of the target end according to the path mapping table until the files under the source path included in the path mapping table are completely migrated; the files under the source path include class files and database configuration files;

[0009] If the file migrated to the target end includes the database configuration file, the database configuration file migrated to the target end is converted from a language applicable to the first database to a language applicable to the second database according to the database language mapping table.

[0010] According to a second aspect of the present application, a device for code migration is provided, including:

[0011] an acquisition unit, configured to acquire a preset path mapping table and a database language mapping table corresponding to the files to be migrated; the path mapping table includes a mapping relationship between a source path and a target path, and the files to be migrated are stored under the source path of the source end; the database language mapping table includes a mapping relationship between a language applicable to the first database and a language applicable to the second database;

[0012] An application migration unit, configured to migrate files under a source path in the source end to a target path in the target end according to the path mapping table, until the files under the source path included in the path mapping table are completely migrated; the files under the source path include class files and database configuration files;

[0013] The database migration unit is configured to convert the database configuration file migrated to the target end from a language applicable to the first database to a language applicable to the second database according to the database language mapping table if the file migrated to the target end includes the database configuration file.

[0014] According to a third aspect of the present application, an electronic device is provided, including a memory and a processor; wherein:

[0015] The memory is used to store computer programs;

[0016] The processor is used to read the computer program stored in the memory and execute the code migration method as described in the first aspect according to the computer program in the memory.

[0017] According to a fourth aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer-executable instructions. When a processor executes the computer-executable instructions, the method for code migration as described in the first aspect is implemented.

[0018] According to a fifth aspect of the present application, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the code migration method as described in the first aspect.

[0019] The present application provides a method, device, equipment, storage medium, and program product for code migration, including: obtaining a preset path mapping table and a database language mapping table corresponding to the files to be migrated; the path mapping table includes a mapping relationship between a source path and a target path, and the files to be migrated are stored under the source path of the source end; the database language mapping table includes a mapping relationship between a language applicable to a first database and a language applicable to a second database; according to the path mapping table, the files under the source path in the source end are migrated to the target path of the target end until the files under the source path included in the path mapping table are migrated; the files under the source path include class files and database configuration files; if the files migrated to the target end include database configuration files, then according to the database language mapping table, the database configuration files migrated to the target end are converted from the language applicable to the first database to the language applicable to the second database. The present application provides a method, device, equipment, storage medium, and program product for code migration, which automatically migrates the code to be migrated by using the preset path mapping table and database language mapping table corresponding to the files to be migrated, without rewriting the code, which is simple and fast, improves the efficiency of code migration, and can ensure the quality of the migrated code. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 A flowchart of a code migration method shown as an exemplary embodiment of the present application;

[0021] Figure 2 A flowchart of a method for initial code migration is shown as an exemplary embodiment of the present application;

[0022] Figure 3 A schematic flow chart of a subsequent code migration method shown as an exemplary embodiment of the present application;

[0023] Figure 4 A structural diagram of a device for code migration shown as an exemplary embodiment of the present application;

[0024] Figure 5 A structural diagram of a code migration device shown as another exemplary embodiment of the present application;

[0025] Figure 6 The figure is a structural diagram of an electronic device according to an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0026] As new technologies continue to emerge, systems are also facing the pressure of continuous iteration at the technical level. In many cases, the system needs to migrate code when the business scenario remains basically unchanged. In the existing technology, traditional code migration is to rewrite and reconstruct the SQL syntax and system application code at the code level.

[0027] However, this method requires rewriting the code, which is time-consuming and labor-intensive. The efficiency of code migration is very low, and the quality of the migrated code cannot be controlled.

[0028] In order to solve the above technical problems, the solution provided in the present application provides a method for code migration, which automatically migrates the code to be migrated by using a preset path mapping table and a database language mapping table corresponding to the file to be migrated. There is no need to rewrite the code, which is simple and fast, improves the efficiency of code migration, and can ensure the quality of the migrated code.

[0029] Figure 1 The flowchart of the code migration method is shown as an exemplary embodiment of the present application.

[0030] like Figure 1 As shown, the code migration method provided in this embodiment includes:

[0031] Step 101, obtain a preset path mapping table and a database language mapping table corresponding to the files to be migrated; the path mapping table includes a mapping relationship between a source path and a target path, and the files to be migrated are stored under the source path of the source end; the database language mapping table includes a mapping relationship between a language applicable to a first database and a language applicable to a second database.

[0032] The method provided in the present application can be performed by an electronic device with computing capabilities, such as a computer. The electronic device can obtain a preset path mapping table and a database language mapping table corresponding to the files to be migrated, and migrate the files to be migrated according to the preset path mapping table and the database language mapping table.

[0033] The files to be migrated may include class files, configuration files or folders under the source path of the source end; wherein the folder may include class files and configuration files. wherein a class file may include an application of the system. one or more class files may constitute the functions of the system.

[0034] Specifically, the code migration method provided in this embodiment can be used in application scenarios where the business scenario is basically unchanged, the business logic is unchanged, and the program development language is unchanged.

[0035] For example, the system originally used distributed logic code developed in Java and distributed database Oceanbase; after migration, the system can use general centralized logic code developed in Java and centralized database Oracle. Through migration, the existing business logic can be more conveniently connected to the general centralized system.

[0036] The path mapping table can be pre-set according to new technologies and business logic, and contains the mapping relationship between source paths and target paths. For example, the source path in the source end has the path ncim-web / com / java. According to the path mapping table, the target path of the target end corresponding to this source path can be ncim-new / com / ncim / java.

[0037] The mapping relationship may be set by the user according to the requirements. For example, the user may determine the storage path of the program code in the target end according to the storage path of the program code in the source end, and then generate a path mapping table according to the mapping relationship.

[0038] The database language mapping table may be pre-set, and includes a mapping relationship between a language applicable to the first database and a language applicable to the second database.

[0039] Specifically, the electronic device can convert the language applicable to the first database into the language applicable to the second database according to the database language mapping table. For example, the first database is applied in the source end, and the second database is applied in the target end. Through the method provided by the present disclosure, the configuration file applicable to the first database in the source end can be converted into a configuration file applicable to the second database, so that the converted configuration file can be applied in the target end.

[0040] Step 102, according to the path mapping table, migrate the files under the source path in the source end to the target path of the target end until the files under the source path included in the path mapping table are completely migrated; the files under the source path include class files and database configuration files.

[0041] Among them, the files under the source path in the source end in the path mapping table are the files to be migrated.

[0042] The files to be migrated may include class files, configuration files or folders. The class files have a corresponding relationship with the configuration files. The configuration files include database configuration files, so the database configuration files also have a corresponding relationship with the class files.

[0043] Furthermore, if the class files in the file to be migrated have references to other class files, the other class files may be migrated according to the path mapping table.

[0044] In actual application, the files under the source path in the path mapping table can be traversed on the source side and mapped to the target path corresponding to the target side. For example, the path mapping table includes the mapping relationship between source path A and target path B, then the files in source path A can be mapped to path B on the target side.

[0045] Step 103: If the file migrated to the target end includes a database configuration file, the database configuration file migrated to the target end is converted from a language applicable to the first database to a language applicable to the second database according to the database language mapping table.

[0046] Specifically, the electronic device migrates the files under the source path in the source end to the target path in the target end according to the path mapping table; wherein the files under the source path include database configuration files. After the database configuration files are migrated, the electronic device can convert the database configuration files migrated to the target end from the language applicable to the first database to the language applicable to the second database according to the database language mapping table.

[0047] Specifically, the code migration method provided in this embodiment may include conversion between standard database language syntaxes to adapt to different databases; wherein the standard database language may be, for example, SQL. For example, the first database may be an oceanbase database developed in SQL; and the second database may be an oracle database developed in SQL.

[0048] Optionally, code migration may include initial code migration and subsequent code migration, wherein initial code migration refers to the first code migration of the system; subsequent code migration refers to the code migration of the system after the first time, wherein subsequent code migration may be more than once.

[0049] Specifically, after the initial code migration, the source code under the source path of the source end in the path mapping table may be modified or new class files may be added; the new code under the corresponding target path of the target end may also be modified or new class files may be added. In order to enable the new code to have the new information in the source code, subsequent code migration may occur after the initial code migration, or even multiple subsequent code migrations may occur.

[0050] The code migration method provided by the present application includes: obtaining a preset path mapping table and a database language mapping table corresponding to the files to be migrated; the path mapping table includes a mapping relationship between a source path and a target path, and the files to be migrated are stored under the source path of the source end; the database language mapping table includes a mapping relationship between a language applicable to a first database and a language applicable to a second database; according to the path mapping table, the files under the source path in the source end are migrated to the target path of the target end until the files under the source path included in the path mapping table are migrated; the files under the source path include class files and database configuration files; if the files migrated to the target end include database configuration files, then according to the database language mapping table, the database configuration files migrated to the target end are converted from the language applicable to the first database to the language applicable to the second database. The code migration method provided by the present application uses the preset path mapping table and the database language mapping table corresponding to the files to be migrated to automatically migrate the code to be migrated, without rewriting the code, which is simple and fast, improves the efficiency of code migration, and can ensure the quality of the migrated code.

[0051] Figure 2 The figure is a flowchart of a method for initial code migration shown as an exemplary embodiment of the present application.

[0052] like Figure 2 As shown, the code migration method provided in this embodiment includes:

[0053] Step 201, obtain a preset path mapping table and a database language mapping table corresponding to the files to be migrated; the path mapping table includes a mapping relationship between a source path and a target path, and the files to be migrated are stored under the source path of the source end; the database language mapping table includes a mapping relationship between a language applicable to a first database and a language applicable to a second database.

[0054] Specifically, after step 201, step 202 may be executed, or step 203 may be executed.

[0055] The implementation method and principle of step 201 are similar to those of step 101 and will not be described in detail.

[0056] Step 202: If the file under the source path is a class file or a configuration file, the file under the source path is migrated to the target path of the target end until the files under the source path included in the path mapping table are completely migrated.

[0057] The source path refers to the path of the source end included in the path mapping table.

[0058] Specifically, the electronic device may migrate the files under the source path to the target path of the corresponding target end according to the path mapping table.

[0059] Specifically, the configuration files in the files under the source path may include a database configuration file; the class files have a corresponding relationship with the configuration files, and therefore, the class files also have a corresponding relationship with the database configuration files.

[0060] In actual application, the files under the source path in the path mapping table can be traversed on the source side and mapped to the target path corresponding to the target side. For example, the path mapping table includes the mapping relationship between source path A and target path B, then the files in source path A can be mapped to path B on the target side.

[0061] Optionally, if all files under the source path are class files or configuration files, all files under the source path are migrated to the target path of the target end.

[0062] Optionally, if the files under the source path include class files or configuration files and also include folders, the class files and configuration files under the source path are migrated to the target path of the target end.

[0063] Step 203, if the file under the source path is a folder, determine whether the path of the folder belongs to the path mapping table; if it does, migrate the folder according to the path mapping table; if it does not, migrate the folder to the target path corresponding to the source path in the target end until the files under the source path included in the path mapping table are completely migrated; the files under the source path include class files and database configuration files.

[0064] Specifically, the file under the source path is a folder, which may contain a class file or a configuration file, wherein the configuration file may include a database configuration file; the class file and the configuration file have a corresponding relationship, and therefore, the class file and the database configuration file also have a corresponding relationship.

[0065] The path of the folder may be a path on the source end. For example, a mapping relationship in the path mapping table includes a source path of ncim-web / com / java; this source path includes folder a, and the path of folder a may be expressed as ncim-web / com / java / a.

[0066] Furthermore, the path mapping table can be used to determine whether the path ncim-web / com / java / a on the source end belongs to the path mapping table. If it does, the files in the folder are migrated to the target path on the target end corresponding to the source path ncim-web / com / java / a according to the path mapping table; if it does not, the folder is migrated to the target path on the target end corresponding to the source path ncim-web / com / java.

[0067] Optionally, if the files migrated to the target end include class files, other class files referenced by the class files and source paths of the other class files are determined based on the content of the class files.

[0068] For example, it can be determined whether there is an import statement in the class file; if so, other class files referenced by the class file are determined based on the content of the import statement in the class file.

[0069] Furthermore, the source paths of other class files can be obtained from the import statements in the class files.

[0070] Determine whether the path mapping table includes the source path of other class files. If included, migrate other class files in the source end to the target end according to the path mapping table; if not included, migrate other class files in the source end to the path where the class files refer to other class files are located, and modify the content used to reference other class files in the class files according to the paths of other class files in the target end.

[0071] For example, the target path of the target end of the class file included in the file to be migrated is ncim-new / com / ncim / java; there is an import statement in the class file, and based on the content of the import statement in the class file, other class files referenced by the class file can be determined; the source path of the other class files can be obtained from the import statement in the class file; based on the path mapping table, it is determined that the source path of the other class files is not in the path mapping table; then the other class files in the source end are migrated to the target path ncim-new / com / ncim / java on the target end.

[0072] Specifically, after the other class files are migrated to the target end, the path of the other class files referenced in the import statement in the migrated class file is modified to be the target path of the other class files on the target end.

[0073] Step 204, if the file migrated to the target end includes a database configuration file, convert the first word in the database configuration file migrated to the target end into a second word according to the database language mapping table, wherein the first word is a language applicable to the first database and the second word is a language applicable to the second database.

[0074] Specifically, according to the database language mapping table, the syntax of the database language can be transformed to adapt to different databases. For example, the database language can be SQL.

[0075] For example, the first database language may be applicable to an oceanbase database, and the second database language may be applicable to an oracle database.

[0076] Specifically, a first word in the first database language can be converted into a second word in the second database language according to a database language mapping table, wherein in the database language mapping table, the first word applicable to the language of the first database corresponds to the second word applicable to the language of the second database.

[0077] Figure 3 The following is a flowchart of a method for subsequent code migration shown as an exemplary embodiment of the present application.

[0078] Specifically, after the initial code migration, if the source code on the source end changes, there may be subsequent code migrations as needed. Figure 3 As shown, the code migration method provided in this embodiment includes:

[0079] Step 301, determining the target path where the class file is located in the target end.

[0080] Specifically, after the initial code migration, both the source code on the source side and the target code on the target side may be changed or new class files may be added.

[0081] Specifically, all class files of the target code may be traversed in the target end to determine the path of each class of files in the target end, that is, determine the target path where each class of files in the target end is located.

[0082] Step 302: Determine the source path corresponding to the target path according to the path mapping table.

[0083] The path mapping table is the path mapping table used during the initial code migration.

[0084] Specifically, according to the path mapping table, a source path corresponding to the target path of the class file in the target end is determined.

[0085] Step 303: Migrate the class file with the same name as the class file under the source path of the source end to the target path of the target end to overwrite the original class file under the target path of the target end.

[0086] When migrating a class file with the same name, a configuration file corresponding to the class file with the same name is also migrated, wherein the configuration file includes a database configuration file.

[0087] The class files with the same name refer to class files with the same name under the target path in the target end and class files with the same name under the source path in the corresponding source end according to the path mapping table.

[0088] Specifically, the class files under the source path in the source end included in the path mapping table may have been modified since the last migration. The method provided in this embodiment can conveniently synchronize the modification of the source code in the source end to the target code in the target end.

[0089] Step 304: Migrate other class files referenced by the class files with the same name according to the path mapping table and the migrated class files with the same name.

[0090] Optionally, other class files referenced by the class file with the same name and source paths of the other class files may be determined based on the content of the migrated class file with the same name.

[0091] For example, it can be determined whether there is an import statement in the class file; if so, other class files referenced by the class file are determined based on the content of the import statement in the class file.

[0092] Furthermore, the source paths of other class files can be obtained from the import statements in the class files.

[0093] Optionally, determine whether the path mapping table includes the source path of other class files. If included, migrate other class files in the source end to the target end according to the path mapping table; if not included, migrate other class files in the source end to the path where the class files refer to other class files are located, and modify the content in the class file used to reference other class files according to the path of other class files in the target end.

[0094] For example, after other class files are migrated to the target end, the path of other class files referenced in the import statement in the migrated class file with the same name is modified to be the target path of other class files on the target end.

[0095] Step 305: According to the path mapping table, determine the class files under the source path of the source end and under the target path of the target end that have different names.

[0096] If a new class file is added under the source path of the source end included in the path mapping table during the next migration after the last migration, a class file with a different name will be generated.

[0097] Specifically, the class files under the source path of the source end included in the path mapping table can be traversed and compared with the class file names included under the target path included in the path mapping table to determine the class files with different names from the target path of the target end.

[0098] Step 306: migrate the class files with different names to the target end according to the path mapping table, and migrate other class files referenced by the class files with different names according to the path mapping table and the migrated class files with different names.

[0099] Specifically, if there are configuration files corresponding to different types of files under the source path in the source end, the configuration files are also migrated simultaneously with the different types of files. The configuration files may include database configuration files.

[0100] Optionally, other class files referenced by the class files with different names and source paths of the other class files may be determined based on the contents of the migrated class files with different names.

[0101] For example, it can be determined whether there is an import statement in the class file; if so, other class files referenced by the class file are determined based on the content of the import statement in the class file.

[0102] Furthermore, the source paths of other class files can be obtained from the import statements in the class files.

[0103] Optionally, determine whether the path mapping table includes the source path of other class files. If included, migrate other class files in the source end to the target end according to the path mapping table; if not included, migrate other class files in the source end to the path where the class files refer to other class files are located, and modify the content in the class file used to reference other class files according to the path of other class files in the target end.

[0104] For example, after other class files are migrated to the target end, the paths of other class files referenced in the import statements in the migrated class files with different names are modified to be the target paths of other class files on the target end.

[0105] Step 307: convert the first word in the database configuration file migrated to the target end into a second word according to the database language mapping table, wherein the first word is a language applicable to the first database and the second word is a language applicable to the second database.

[0106] The implementation method and principle of step 307 are similar to those of step 204 and will not be described in detail.

[0107] Figure 4 A structural diagram of a code migration device shown as an exemplary embodiment of the present application.

[0108] like Figure 4 As shown, the code migration device 400 provided by the present application includes:

[0109] The acquisition unit 410 is used to acquire a preset path mapping table and a database language mapping table corresponding to the files to be migrated; the path mapping table includes a mapping relationship between a source path and a target path, and the files to be migrated are stored under the source path of the source end; the database language mapping table includes a mapping relationship between a language applicable to the first database and a language applicable to the second database;

[0110] The application migration unit 420 is used to migrate the files under the source path in the source end to the target path of the target end according to the path mapping table until the files under the source path included in the path mapping table are completely migrated; the files under the source path include class file database configuration files;

[0111] The database migration unit 430 is configured to convert the database configuration file migrated to the target end from a language applicable to the first database to a language applicable to the second database according to the database language mapping table if the file migrated to the target end includes a database configuration file.

[0112] Figure 5 A structural diagram of a code migration device shown in another exemplary embodiment of the present application.

[0113] like Figure 5 As shown, based on the above embodiment, in the code migration device 500 provided by the present application, the application migration unit 420 includes:

[0114] The class file migration module 421 is used to migrate the file under the source path to the target path of the target end if the file under the source path is a class file or a configuration file.

[0115] The folder migration module 422 is used to determine whether the path of the folder belongs to the path mapping table if the file under the source path is a folder; if it does, migrate the folder according to the path mapping table; if it does not, migrate the folder to the target path corresponding to the source path in the target end.

[0116] The application migration unit 420 is also used to determine other class files referenced by the class file and the source path of the other class files based on the content in the class file if the file migrated to the target end includes the class file; determine whether the source path of the other class files is included in the path mapping table; if included, migrate the other class files in the source end to the target end according to the path mapping table; if not included, migrate the other class files in the source end to the path where the class files that reference the other class files are located, and modify the content in the class file used to reference the other class files based on the path of the other class files in the target end.

[0117] The database migration unit 430 is specifically configured to convert a first word in a database configuration file migrated to a target end into a second word according to a database language mapping table, wherein the first word is a language applicable to a first database and the second word is a language applicable to a second database.

[0118] The application migration unit 420 is also used to determine the target path where the class file is located in the target end; determine the source path corresponding to the target path according to the path mapping table; migrate the class file with the same name corresponding to the class file under the source path of the source end to the target path of the target end to overwrite the original class file under the target path of the target end; migrate other class files referenced by the class file with the same name according to the path mapping table and the migrated class file with the same name.

[0119] The application migration unit 420 is also used to determine, according to the path mapping table, class files with different names under the source path of the source end and under the target path of the target end; migrate the class files with different names to the target end according to the path mapping table, and migrate other class files referenced by the class files with different names according to the path mapping table and the migrated class files with different names.

[0120] Figure 6 The figure is a structural diagram of an electronic device according to an exemplary embodiment of the present application.

[0121] like Figure 6 As shown, the electronic device provided in this embodiment includes:

[0122] Memory 601;

[0123] Processor 602; and

[0124] Computer programs;

[0125] The computer program is stored in the memory 601 and is configured to be executed by the processor 602 to implement any of the above code migration methods.

[0126] This embodiment also provides a computer-readable storage medium having a computer program stored thereon.

[0127] The computer program is executed by a processor to implement any of the above code migration methods.

[0128] This embodiment also provides a computer program product, including a computer program, which implements any of the above code migration methods when executed by a processor.

[0129] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.

[0130] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for code migration, characterized in that: include: Acquire a preset path mapping table and a database language mapping table corresponding to the files to be migrated; the path mapping table includes a mapping relationship between a source path and a target path, and the files to be migrated are stored under the source path of the source end; the database language mapping table includes a mapping relationship between a language applicable to the first database and a language applicable to the second database; Migrating the files under the source path in the source end to the target path of the target end according to the path mapping table until the files under the source path included in the path mapping table are completely migrated; the files under the source path include class files and database configuration files; If the file migrated to the target end includes the database configuration file, converting the database configuration file migrated to the target end from a language applicable to the first database to a language applicable to the second database according to the database language mapping table; Migrating the file under the source path in the source end to the target path in the target end according to the path mapping table includes: If the file under the source path is a class file or a configuration file, the file under the source path is migrated to the target path of the target end; If the file migrated to the target end is a class file, the method further includes: Determine other class files referenced by the class file and source paths of the other class files according to the content of the class file; Determine whether the path mapping table includes the source path of the other class file; If included, other class files in the source end are migrated to the target end according to the path mapping table; If not included, the other class files in the source end are migrated to the path where the class files referencing the other class files are located, and the content in the class files used to refer to the other class files is modified according to the paths of the other class files on the target end; The step of converting the database configuration file migrated to the target end from a language applicable to the first database to a language applicable to the second database according to the database language mapping table includes: According to the database language mapping table, a first word in the database configuration file migrated to the target end is converted into a second word, wherein the first word is a language applicable to the first database and the second word is a language applicable to the second database.

2. The method according to claim 1, characterized in that Migrating the file under the source path in the source end to the target path in the target end according to the path mapping table includes: if the file under the source path is a folder, determining whether the path of the folder belongs to the path mapping table; if it does, migrating the folder according to the path mapping table; If not, the folder is migrated to a target path on the target end that corresponds to the source path.

3. The method according to claim 1, characterized in that: Also includes: Determining a target path where the class file is located in the target end; Determine, according to the path mapping table, a source path corresponding to the target path; Migrating the class file with the same name as the class file under the source path of the source end to the target path of the target end to overwrite the original class file under the target path of the target end; According to the path mapping table and the migrated class files with the same name, other class files referenced by the class files with the same name are migrated.

4. The method according to claim 1, characterized in that: Also includes: According to the path mapping table, determining a class file with a different name from that under the target path of the target end under the source path of the source end; The class files with different names are migrated to the target end according to the path mapping table, and other class files referenced by the class files with different names are migrated according to the path mapping table and the migrated class files with different names.

5. A device for code migration, characterized in that: include: an acquisition unit, configured to acquire a preset path mapping table and a database language mapping table corresponding to the files to be migrated; the path mapping table includes a mapping relationship between a source path and a target path, and the files to be migrated are stored under the source path of the source end; the database language mapping table includes a mapping relationship between a language applicable to the first database and a language applicable to the second database; An application migration unit, configured to migrate files under a source path in the source end to a target path in the target end according to the path mapping table, until the files under the source path included in the path mapping table are completely migrated; the files under the source path include class files and database configuration files; a database migration unit, configured to convert the database configuration file migrated to the target end from a language applicable to the first database to a language applicable to the second database according to the database language mapping table if the file migrated to the target end includes the database configuration file; The application migration unit includes: A class file migration module, used for migrating the file under the source path to the target path of the target end if the file under the source path is a class file or a configuration file; The application migration unit is further used for, if the file migrated to the target end includes a class file, determining other class files referenced by the class file and the source path of the other class files according to the content of the class file; determining whether the path mapping table includes the source path of the other class files; if it does, migrating the other class files in the source end to the target end according to the path mapping table; if it does not, migrating the other class files in the source end to the path where the class files refer to the other class files are located, and modifying the content in the class file for referencing the other class files according to the path of the other class files on the target end; The database migration unit is specifically used to convert a first word in a database configuration file migrated to the target end into a second word according to the database language mapping table, wherein the first word is a language applicable to the first database and the second word is a language applicable to the second database.

6. An electronic device, characterized in that: comprising a memory and a processor; wherein, The memory is used to store computer programs; The processor is used to read the computer program stored in the memory and execute the method according to any one of claims 1 to 4 according to the computer program in the memory.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the processor executes the computer-executable instructions, the method described in any one of claims 1 to 4 is implemented.

8. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method described in any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Heterogeneous database data migration method, device and equipment

    CN112181951A

  • Program code conversion method and related equipment

    CN112667240A