Application migration methods, apparatus, devices and storage media

By automatically synchronizing and migrating the application's source code using a target matching model and transformation rules, the problem of long migration times in database migration was solved, improving development efficiency and migration accuracy.

CN116185468BActive Publication Date: 2026-07-17华润数字科技有限公司

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
华润数字科技有限公司
Filing Date
2023-02-21
Publication Date
2026-07-17

AI Technical Summary

Technical Problem

During application migration, the syntax differences between different databases result in a long migration time for the source code, a large workload for manual analysis and compatibility modifications, and low development efficiency.

Method used

By using a preset target matching model and transformation rules, the source code files are automatically matched and transformed to achieve automatic synchronous migration of the application's source code project package. The regular expression engine and configuration transformation rules are used to match and transform the text to be processed in the source code files.

Benefits of technology

It reduces the time spent on source code migration, improves development efficiency and migration accuracy, and ensures the quality of source code migration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116185468B_ABST
    Figure CN116185468B_ABST
Patent Text Reader

Abstract

This application provides an application migration method, apparatus, device, and storage medium, belonging to the field of application migration technology. The method includes: receiving a migration instruction; responding to the migration instruction, obtaining the application's source code project package, wherein the source code project package includes multiple source code files, and the migration instruction is used to instruct the migration of the database connected to the application from a source database to a target database; performing matching processing on the source code files using a preset target matching model to match and identify a file to be processed among the multiple source code files, wherein the target matching model corresponds to the migration instruction; and performing modification processing on the file to be processed using preset target modification rules to obtain a modified file to update the source code project package, wherein the target modification rules correspond to the migration instruction. This application embodiment can reduce the time consumed in the source code migration process, thereby improving development efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to, but is not limited to, the field of application migration technology, and in particular to an application migration method, apparatus, device, and storage medium. Background Technology

[0002] In different application scenarios, the database that the application connects to may need to be migrated. Since different databases have different syntaxes, after the database is migrated, the application's source code needs to be migrated synchronously so that the application can effectively access the migrated database.

[0003] Currently, during application migration, developers need to analyze the differences between the source and target databases and then manually migrate the application's source code. However, the source code is usually quite complex, and the workload of manual analysis and compatibility modifications is large, resulting in a long migration process and low development efficiency. Summary of the Invention

[0004] The following is an overview of the subject matter described in detail herein. This overview is not intended to limit the scope of the claims.

[0005] This application provides an application migration method, apparatus, device, and storage medium that can reduce the time spent in the source code migration process, thereby improving development efficiency.

[0006] To achieve the above objectives, a first aspect of this application proposes an application migration method, comprising: receiving a migration instruction; responding to the migration instruction, obtaining a source code project package of the application, wherein the source code project package includes multiple source code files, and the migration instruction is used to instruct the migration of a database connected to the application from a source database to a target database; performing matching processing on the source code files using a preset target matching model to match a file to be processed among the multiple source code files, wherein the target matching model corresponds to the migration instruction; and performing modification processing on the file to be processed using a preset target modification rule to obtain a modified file to update the source code project package, wherein the target modification rule corresponds to the migration instruction.

[0007] In some embodiments, the target matching model is a regular expression engine, which is configured with multiple configuration regular expressions and SQL regular expressions; the step of using a preset target matching model to match the source code files and matching the file to be processed among the multiple source code files includes: matching the text in the source code files according to the configuration regular expressions and the SQL regular expressions; for any source code file, when the text in the source code file matches any of the configuration regular expressions, it is determined that the source code file contains configuration text to be converted, wherein the configuration text to be converted... The configuration text refers to the text within the source code file that matches the configuration regular expression, and the configuration text to be converted corresponds to the source database. For any source code file, when the text within the source code file matches any SQL regular expression, it is determined that the source code file contains SQL text to be converted, wherein the SQL text to be converted refers to the text within the source code file that matches the SQL regular expression, and the SQL text to be converted corresponds to the source database. Among multiple source code files, the source code file containing the configuration text to be converted or the SQL text to be converted is designated as the file to be processed.

[0008] In some embodiments, the target transformation rule includes configuration conversion rules and SQL conversion rules; the step of transforming the file to be processed using the preset target transformation rules to obtain a transformed file includes: when the file to be processed contains the configuration text to be transformed, the configuration text to be transformed is transformed using the configuration conversion rules to obtain target configuration text, and the file to be processed is transformed according to the target configuration text, wherein the target configuration text corresponds to the target database; when the file to be processed contains the SQL text to be transformed, the SQL text to be transformed is transformed using the SQL conversion rules to obtain target SQL text, and the file to be processed is transformed according to the target SQL text, wherein the target SQL text corresponds to the target database; and the transformed file is obtained from the transformed file to be processed.

[0009] In some embodiments, after the step of obtaining the modified file based on the modified file to be processed, the method further includes: determining modification path information and modification location information based on the modified file and the source code project package, wherein the modification path information is used to indicate the path of the modified file in the source code project package, and the modification location information is used to indicate the location of the target configuration text or the target SQL text within the modified file; and generating a record report based on the filename of the modified file, the modification path information, and the modification location information.

[0010] In some embodiments, before the step of obtaining the modified file based on the modified file to be processed, the method further includes: detecting whether a configuration modification request for the target configuration text is received; when the configuration modification request is received, modifying the target configuration text according to the configuration modification request, and modifying the file to be processed based on the modified target configuration text; detecting whether an SQL modification request for the target SQL text is received; when the SQL modification request is received, modifying the target SQL text according to the SQL modification request, and modifying the file to be processed based on the modified target SQL text.

[0011] In some embodiments, the target matching model is configured with multiple main matching rules and several auxiliary matching rules, wherein the auxiliary matching rules correspond to the main matching rules; the step of using the preset target matching model to match the source code files and matching the files to be processed among the multiple source code files includes: inputting the source code files into the target matching model and performing matching processing on the source code files; traversing the main matching rules, among the multiple source code files, taking the source code files that conform to the main matching rules as intermediate files, and determining whether the main matching rules correspond to auxiliary matching rules; when the main matching rules correspond to auxiliary matching rules, and the intermediate files conform to the auxiliary matching rules, taking the intermediate files as files to be processed.

[0012] In some embodiments, the target matching model is obtained through the following steps: performing a difference analysis on the source database and the target database to determine the difference information; extracting features from the difference information to determine multiple pattern features; determining the feature regular expression corresponding to the pattern feature based on the pattern feature, and obtaining the target matching model based on the feature regular expression.

[0013] To achieve the above objectives, a second aspect of this application provides an application migration apparatus, comprising: a receiving unit for receiving a migration instruction; an acquiring unit for acquiring an application source code package in response to the migration instruction, wherein the source code package includes multiple source code files, and the migration instruction instructs the migration of a database connected to the application from a source database to a target database; a matching unit for matching the source code files using a preset target matching model to identify a file to be processed among the multiple source code files, wherein the migration instruction instructs the source database and target database corresponding to the application, and the target matching model corresponds to the migration instruction; and a modification unit for modifying the file to be processed using preset target modification rules to obtain a modified file to update the source code package, wherein the target modification rules correspond to the migration instruction.

[0014] To achieve the above objectives, a third aspect of this application provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the application migration method described in the first aspect.

[0015] To achieve the above objectives, a fourth aspect of the present application provides a storage medium, which is a computer-readable storage medium storing a computer program that, when executed by a processor, implements the application migration method described in the first aspect.

[0016] The application migration method, apparatus, device, and storage medium proposed in this application include, in embodiments thereof: receiving a migration instruction; responding to the migration instruction, obtaining the source code project package of the application, wherein the source code project package includes multiple source code files, and the migration instruction is used to instruct the database to which the application is connected to be migrated from a source database to a target database; performing matching processing on the source code files using a preset target matching model to match and identify a file to be processed among the multiple source code files, wherein the target matching model corresponds to the migration instruction; and performing modification processing on the file to be processed using a preset target modification rule to obtain a modified file to update the source code project package, wherein the target modification rule corresponds to the migration instruction. According to the solution provided in the embodiments of this application, after receiving the migration instruction, the database connected to the application needs to be migrated. During the migration process, the target matching model is used to match the files to be modified in the source code files. Then, the target modification rules are used to modify the files to be modified to obtain the modified files, thereby updating the source code project package. The target matching model and the target modification rules are both corresponding to the migration instruction, which can effectively migrate the database connected to the application from the source database to the target database. This realizes the automatic synchronous migration of the application's source code project package. Compared with manual migration, it can reduce the time spent in the source code migration process, thereby improving development efficiency. In addition, it can also improve the accuracy of source code migration and ensure the quality of source code migration.

[0017] Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the description, claims and drawings. Attached Figure Description

[0018] The accompanying drawings are used to provide a further understanding of the technical solutions of this application and constitute a part of the specification. They are used together with the embodiments of this application to explain the technical solutions of this application and do not constitute a limitation on the technical solutions of this application.

[0019] Figure 1 This is a flowchart of an application migration method provided in one embodiment of this application;

[0020] Figure 2 This is a flowchart of a matching process method provided in another embodiment of this application;

[0021] Figure 3 This is a flowchart of a modification process provided in another embodiment of this application;

[0022] Figure 4This is a flowchart of a method for generating a record report provided in another embodiment of this application;

[0023] Figure 5 This is a flowchart of a modification process provided in another embodiment of this application;

[0024] Figure 6 This is a flowchart of another matching process method provided in another embodiment of this application;

[0025] Figure 7 This is a flowchart of a method for obtaining a target matching model provided in another embodiment of this application;

[0026] Figure 8 This is a schematic diagram of the structure of an application migration device provided in another embodiment of this application;

[0027] Figure 9 This is a schematic diagram of the hardware structure of an electronic device provided in another embodiment of this application. Detailed Implementation

[0028] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0029] In the description of this application, "several" means one or more, "multiple" means two or more, "greater than", "less than", "exceeding" etc. are understood to exclude the number itself, and "above", "below", "within" etc. are understood to include the number itself.

[0030] It should be noted that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, or the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.

[0031] Currently, during application migration, developers need to analyze the differences between the source and target databases and then manually migrate the application's source code. However, the source code is usually quite complex, and the workload of manual analysis and compatibility modifications is large, resulting in a long migration process and low development efficiency.

[0032] To address the problem of long development efficiency caused by the time-consuming source code migration process, this application provides an application migration method, apparatus, device, and storage medium. The method includes: receiving a migration instruction; responding to the migration instruction by obtaining the application's source code project package, wherein the source code project package includes multiple source code files, and the migration instruction is used to instruct the migration of the database connected to the application from a source database to a target database; performing matching processing on the source code files using a preset target matching model to match the files to be processed among the multiple source code files, wherein the target matching model corresponds to the migration instruction; and performing modification processing on the files to be processed using preset target modification rules to obtain modified files to update the source code project package, wherein the target modification rules correspond to the migration instruction. According to the solution provided in the embodiments of this application, after receiving the migration instruction, the database connected to the application needs to be migrated. During the migration process, the target matching model is used to match the files to be modified in the source code files. Then, the target modification rules are used to modify the files to be modified to obtain the modified files, thereby updating the source code project package. The target matching model and the target modification rules are both corresponding to the migration instruction, which can effectively migrate the database connected to the application from the source database to the target database. This realizes the automatic synchronous migration of the application's source code project package. Compared with manual migration, it can reduce the time spent in the source code migration process, thereby improving development efficiency. In addition, it can also improve the accuracy of source code migration and ensure the quality of source code migration.

[0033] The application migration method, apparatus, device, and storage medium provided in this application embodiment are specifically described through the following embodiments. First, the application migration method in this application embodiment is described.

[0034] The application migration method provided in this application relates to the field of data processing technology. The application migration method provided in this application can be applied to a terminal, a server, or software running on either a terminal or a server. In some embodiments, the terminal can be a smartphone, tablet, laptop, desktop computer, etc.; the server can be configured as an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application implementing the application migration method, but is not limited to the above forms.

[0035] This application can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0036] It should be noted that in all specific embodiments of this application, when processing data related to user identity or characteristics, such as user information, user behavior data, user historical data, and user location information, user permission or consent is obtained first. Furthermore, the collection, use, and processing of this data comply with relevant laws, regulations, and standards of the relevant countries and regions. In addition, when embodiments of this application require access to sensitive personal information of users, separate permission or consent from the user is obtained through pop-ups or redirects to confirmation pages. Only after obtaining the user's separate permission or consent is the necessary user-related data for the proper functioning of the embodiments of this application obtained.

[0037] First, let's clarify some of the terms used in this invention:

[0038] DM Database is a high-performance database management system with completely independent intellectual property rights launched by DM Company. While ensuring large-scale general use, DM Database has carried out a lot of research and development and improvement work on reliability, high performance, massive data processing and security, which greatly improves the performance, reliability and scalability of DM Database products and can simultaneously handle OLTP and OLAP requests.

[0039] Oracle Database is a relational database management system developed by Oracle Corporation. It is highly portable, easy to use, and powerful, suitable for various large, medium, and small computer environments, and boasts advantages such as high efficiency, high reliability, and adaptability to high throughput.

[0040] A Java application is a program developed using Java. Java adopts an object-oriented programming approach. Applications developed using Java can run on a single computer or distributed across a network of servers and clients.

[0041] The embodiments of this application will be further described below with reference to the accompanying drawings.

[0042] like Figure 1 As shown, Figure 1 This is a flowchart illustrating an application migration method according to an embodiment of this application. The application migration method includes, but is not limited to, the following steps:

[0043] Step S110: Receive migration instructions;

[0044] Step S120: In response to the migration instruction, obtain the source code project package of the application, wherein the source code project package includes multiple source code files, and the migration instruction is used to instruct the database to be migrated from the source database to the target database.

[0045] Step S130: Use a preset target matching model to match the source code files and match the files to be processed in multiple source code files. The target matching model corresponds to the migration instructions.

[0046] Step S140: Modify the file to be processed using the preset target modification rules to obtain the modified file, so as to update the source code project package. The target modification rules correspond to the migration instructions.

[0047] Understandably, with the migration and transformation of databases, many Java applications currently based on Oracle databases need to be migrated to DM databases. Oracle and DM databases have different product characteristics, and there is coupling between the database and the Java application. To ensure the normal operation of the application, it needs to be modified and adapted accordingly to run normally on the new database. Oracle database is equivalent to the source database, and DM database is equivalent to the target database. By obtaining the source syntax information corresponding to the source database and the target syntax information corresponding to the target database, and then using the source and target syntax information, the syntax differences between the target and source databases are determined. Furthermore, the syntax difference information is used to determine the target matching model and target transformation rules, and finally, the target matching model is used to match the application to be migrated. The system processes files and uses target modification rules to modify them, enabling application conversion and adaptation without manual migration, thus improving development efficiency. Based on this, upon receiving a migration instruction, the database connected to the application needs to be migrated. During the migration process, a target matching model is used to match the files to be modified in the source code files. Then, the target modification rules are used to modify the files to obtain the modified files, thereby updating the source code project package. Both the target matching model and the target modification rules correspond to the migration instruction, effectively migrating the database connected to the application from the source database to the target database. This achieves automatic synchronous migration of the application's source code project package. Compared to manual migration, this reduces the time spent on the source code migration process, thereby improving development efficiency. Furthermore, it also improves the accuracy of the source code migration, ensuring its quality.

[0048] It should be noted that the steps to obtain the application's source code package include: obtaining the application's application information; determining the source code address based on the application information; and obtaining the application's source code package based on the source code address. The application information refers to information related to the application migration process, including but not limited to: the source code package or GitLab code repository address, access token, branches, dependency management tools (Maven or Gradle), and JDK version information. Application information is essential input for the application conversion and adaptation process, and each application to be converted and adapted maintains one set of application data.

[0049] In practice, after the source code project package is updated, it needs to be compiled, packaged, and deployed to obtain the updated application.

[0050] Additionally, refer to Figure 2 In one embodiment, the target matching model is a regular expression engine, which is configured with multiple configuration regular expressions and SQL regular expressions; Figure 1Step S130 in the illustrated embodiment includes, but is not limited to, the following steps:

[0051] Step S210: Match the text in the source code file according to the configured regular expression and the SQL regular expression;

[0052] Step S220: For any source code file, when the text in the source code file matches any configuration regular expression, it is determined that the source code file contains configuration text to be converted. Here, the configuration text to be converted refers to the text in the source code file that matches the configuration regular expression, and the configuration text to be converted corresponds to the source database.

[0053] Step S230: For any source code file, when the text in the source code file matches any SQL regular expression, it is determined that the source code file contains SQL text to be converted. The SQL text to be converted refers to the text in the source code file that matches the SQL regular expression, and the SQL text to be converted corresponds to the source database.

[0054] Step S240: Among multiple source code files, the source code file containing the configuration text or SQL text to be converted is selected as the file to be processed.

[0055] Understandably, the configuration text corresponding to the source database and the configuration text corresponding to the target database have different configuration syntax in the source code files. Based on the regular expression engine, configuration regular expressions are generated based on these syntax differences. Each configuration regular expression corresponds one-to-one with the type of the configuration syntax difference. These regular expressions are used to match and extract the configuration text to be transformed. During the application migration process, by scanning the text in each source code file, all transformed configuration text is matched using the configuration regular expressions, and the source code file containing the configuration text to be transformed is designated as the file to be processed. Additionally, the SQL text corresponding to the source database and the SQL text corresponding to the target database have different SQL syntax. Based on the regular expression engine, SQL regular expressions are generated based on these syntax differences. Each SQL regular expression corresponds one-to-one with the type of the SQL syntax difference, and these regular expressions are used to match and extract the SQL text to be transformed. During the application migration process, by scanning the text in each source code file, all transformed SQL text is matched using the SQL regular expressions, and the source code file containing the SQL text to be transformed is designated as the file to be processed.

[0056] It should be noted that developers can manually modify the configuration regular expressions and SQL regular expressions to improve text matching efficiency and accuracy.

[0057] In practical application, when the source database is an Oracle database and the target database is a DM database, the configuration syntax differences between Oracle and DM databases are addressed by generating configuration regular expressions based on the regular expression engine. These configuration regular expressions include, but are not limited to, "*?dialect[\w\d\.]*", "(?", ... <dbusername>The regular expression ")\n.*)" can match the configuration text to be transformed; based on the SQL syntax differences between Oracle database and DM database, the regular expression engine generates SQL regular expressions through the SQL syntax differences. The SQL regular expressions include, but are not limited to: "remainder\s*" and "(?)CLOB". The SQL regular expressions can match the SQL text to be transformed.

[0058] In another embodiment, Figure 2 Step S210 in the illustrated embodiment includes, but is not limited to, the following steps:

[0059] Based on the filename of the source code file and the preset name filtering rules, determine the configuration file in the source code file;

[0060] Based on the configured regular expressions, the text in the configuration file is matched and processed;

[0061] The text within the source code file is matched and processed based on SQL regular expressions.

[0062] Understandably, before the matching process, the configuration file is determined in the source code file by using name filtering rules. The configuration text to be converted is located in the configuration file. The total number of source code files is much smaller than the total number of texts in the source code files. First, the configuration file is filtered out by name filtering rules, and then the configuration regular expression is used to perform targeted matching processing on the configuration file, which can effectively improve the matching efficiency.

[0063] In practice, configuration files in Java applications have fixed filename suffixes. For example, name filtering rules include, but are not limited to, *.xml, *.properties, *.yaml, and *.yml. Name filtering rules can filter out configuration files with filename suffixes of xml, properties, yaml, and yml.

[0064] Additionally, refer to Figure 3 In one embodiment, the target transformation rules include configuration transformation rules and SQL transformation rules; Figure 1 Step S140 in the illustrated embodiment includes, but is not limited to, the following steps:

[0065] Step S310: When the file to be processed contains configuration text to be converted, the configuration text to be converted is converted using configuration conversion rules to obtain target configuration text, and the file to be processed is modified according to the target configuration text, wherein the target configuration text corresponds to the target database.

[0066] Step S320: When the file to be processed contains SQL text to be converted, the SQL text to be converted is processed using SQL conversion rules to obtain the target SQL text, and the file to be processed is modified according to the target SQL text, wherein the target SQL text corresponds to the target database.

[0067] Step S330: Obtain the modified file based on the modified file to be processed.

[0068] Understandably, in the source code files, there are differences in configuration syntax between the configuration text corresponding to the source database and the configuration text corresponding to the target database. After generating a configuration regular expression based on these differences, the content in the configuration text that needs to be converted can be determined, thereby determining the configuration conversion rules. These conversion rules are used to convert the configuration text to be converted from the source database to the target configuration text corresponding to the target database. Additionally, there are differences in SQL syntax between the SQL text corresponding to the source database and the target database. After generating an SQL regular expression based on these differences, the content in the SQL text that needs to be converted can be determined, thereby determining the SQL conversion rules. These conversion rules are used to convert the SQL text to be converted from the source database to the target SQL text corresponding to the target database.

[0069] In practice, configuration transformation rules correspond to configuration regular expressions, for example...

[0070] The first configuration regular expression is: "*?dialect[\w\d\.]*",

[0071] The corresponding first configuration conversion rule is: "${prefix}org.hibernate.dialect.DmDialect";

[0072] The second configuration regular expression is: "(?" <dbusername>)\n.*)”

[0073] The corresponding second configuration conversion rule is: "${origin}#\{\['${dbusername}'\]\}";

[0074] SQL transformation rules correspond to SQL regular expressions, for example,

[0075] The first SQL regular expression is: "remainder\s*".

[0076] The corresponding first SQL transformation rule is: "MOD\(${origin}\);

[0077] The second SQL regular expression is: "(?)CLOB".

[0078] The corresponding second SQL conversion rule is: "Clob".

[0079] Additionally, refer to Figure 4 In one embodiment, Figure 3 Following step S330 in the illustrated embodiment, the following steps may also be included, but are not limited to:

[0080] Step S410: Based on the modification file and the source code project package, determine the modification path information and modification location information. The modification path information is used to indicate the path of the modification file in the source code project package, and the modification location information is used to indicate the location of the target configuration text or target SQL text within the modification file.

[0081] Step S420: Generate a record report based on the file name, modification path information, and modification location information of the modified file.

[0082] Understandably, once the files to be processed are modified, a log report will be automatically generated. The log report will record the file name, modification path information, and modification location information of the modified file. The modification path information indicates the path of the modified file in the source code project package, and the modification location information indicates the location of the target configuration text or target SQL text within the modified file. By viewing the log report, developers can quickly understand the modification content of the application, which facilitates the further improvement of matching models and transformation rules, and improves the migration quality of the application.

[0083] Referring to Table 1, which is a recording report provided in this application embodiment, the recording report table includes a file name column, a file path column, and a statement position column. The file name column is used to record the file name of the modified file, the file path column is used to record the path of the modified file in the source code project package, and the statement position column is used to record the position of the target configuration text or target SQL text within the modified file. In addition, to improve development efficiency, the recording report table also includes a source statement column, a target statement column, and an adaptation status column. The source statement refers to the configuration text or SQL text to be converted, and the target statement refers to the target configuration text or target SQL text. The source statement column is used to record the configuration text or SQL text to be converted, the target statement column is used to record the target configuration text or target SQL text, and the adaptation status column is used to record the migration status. A successful adaptation status means that the source statement has been successfully converted into the target statement, and a failed adaptation status means that the source statement has not been converted into the target statement.

[0084] Table 1

[0085] File Name File path Statement position Source statement target statement Adaptation status H1 / Path1 100-110 to_nchar TO_CHAT success H2 / Path2 500-550 sys.dual DUAL success

[0086] Additionally, refer to Figure 5 In one embodiment, Figure 3 Before step S330 in the illustrated embodiment, the following steps may also be included, but are not limited to:

[0087] Step S510: Detect whether a configuration modification request for the target configuration text has been received;

[0088] Step S520: When a configuration modification request is received, the target configuration text is modified according to the configuration modification request, and the file to be processed is modified according to the modified target configuration text.

[0089] Step S530: Detect whether an SQL modification request for the target SQL text has been received;

[0090] Step S540: When an SQL modification request is received, the target SQL text is modified according to the SQL modification request, and the file to be processed is modified according to the modified target SQL text.

[0091] Understandably, before updating the source code project package, developers should be able to know the changes to the application. For example, the configuration text to be converted, the SQL text to be converted, the target configuration text, the target SQL text, and the related source code files can be recorded in a configuration parsing table and displayed in the display module. This allows developers to know the changes to the source code project package through the configuration parsing table. When developers need to modify the changes, they can modify the target configuration text by entering a configuration modification request, or modify the target SQL text by entering an SQL modification request. The source code project package is only updated after the developers have confirmed that the information in the configuration parsing table is correct, thus ensuring the reliability of the source code project package.

[0092] It should be noted that, in addition to learning about the modifications to the source code package through the configuration resolution table, developers can also learn about the modifications to the source code package through other means, which are not limited here.

[0093] Additionally, refer to Figure 6 In one embodiment, the target matching model is configured with multiple main matching rules and several auxiliary matching rules, and the auxiliary matching rules correspond to the main matching rules; Figure 1 Step S130 in the illustrated embodiment includes, but is not limited to, the following steps:

[0094] Step S610: Input the source code file into the target matching model and perform matching processing on the source code file;

[0095] Step S620: Traverse the main matching rules, select the source files that match the main matching rules as intermediate files from multiple source files, and determine whether the main matching rules correspond to auxiliary matching rules.

[0096] Step S630: When there is an auxiliary matching rule corresponding to the main matching rule, and the intermediate file meets the auxiliary matching rule, the intermediate file is treated as a file to be processed.

[0097] Understandably, for source code files with complex content structures, a single matching rule cannot accurately match the files to be processed. It is necessary to configure primary and secondary matching rules. First, the primary matching rule is used to perform an initial match on the files to be processed, and the source code files that match the primary matching rule are used as intermediate files. Then, it is determined whether the primary matching rule corresponds to a secondary matching rule. If the primary matching rule corresponds to a secondary matching rule, it means that the content to be matched is relatively complex, and the secondary matching rule needs to be used to perform auxiliary matching on the intermediate files. When the intermediate file matches the secondary matching rule, the intermediate file is used as the file to be processed. When the intermediate file does not match the secondary matching rule, it means that the intermediate file does not meet the conditions to be used as the file to be processed. By combining the primary and secondary matching rules for matching, the matching accuracy of the files to be processed can be effectively improved.

[0098] It should be noted that when the main matching rule does not have a corresponding auxiliary matching rule, it means that the matching content is relatively simple and there is no need to perform auxiliary matching. The intermediate file can be directly used as the file to be processed.

[0099] In practice, a primary matching rule can correspond to one or more secondary matching rules, or a primary matching rule may not have a corresponding secondary matching rule. For example, when the matching content is a CLOB-related declaration, the primary matching rule is: "(?<!\w|\.|_)CLOB", and the secondary matching rule is: "import\s+oracle.sql.CLOB".

[0100] Additionally, refer to Figure 7 In one embodiment, Figure 1 The target matching model in step S130 of the illustrated embodiment is obtained through the following steps:

[0101] Step S710: Perform a difference analysis on the source database and the target database to determine the difference information;

[0102] Step S720: Extract features from the difference information to determine multiple pattern features;

[0103] Step S730: Based on the pattern features, determine the feature regular expression corresponding to the pattern features, and obtain the target matching model based on the feature regular expression.

[0104] Understandably, during the R&D process, difference analysis can be used to determine the differences between the source and target databases. For example, based on the differences in application logic code and configuration between Oracle and DM databases, schema features can be extracted, and then feature regular expressions can be determined. The feature regular expressions correspond one-to-one with the schema features. For example, the feature regular expressions may be configuration regular expressions or SQL regular expressions. By fusing all feature regular expressions, a target matching model can be obtained, which can accurately identify the file to be processed. Furthermore, corresponding configuration conversion rules and SQL conversion rules can be generated based on the schema features, thereby determining the target modification rules and effectively modifying the file to be processed.

[0105] Additionally, refer to Figure 8 This application also provides an application migration apparatus 800, comprising:

[0106] The receiving unit 810 is used to receive migration instructions;

[0107] The acquisition unit 820 is used to acquire the source code project package of the application in response to the migration instruction. The source code project package includes multiple source code files. The migration instruction is used to instruct the database to which the application is connected to to be migrated from the source database to the target database.

[0108] The matching unit 830 is used to match source code files using a preset target matching model, and to match the file to be processed in multiple source code files. The migration instruction is used to indicate the source database and target database corresponding to the application, and the target matching model corresponds to the migration instruction.

[0109] The modification unit 840 is used to modify the file to be processed using preset target modification rules to obtain modified files for updating the source code project package. The target modification rules correspond to migration instructions.

[0110] It is understood that the specific implementation of the application migration device 800 is basically the same as the specific implementation of the application migration method described above, and will not be repeated here. Based on this, after receiving the migration instruction, it is necessary to migrate the database connected to the application. During the migration process, the target matching model is used to match the files to be modified in the source code files. Then, the target modification rules are used to modify the files to be modified to obtain the modified files, and then the source code project package is updated. The target matching model and the target modification rules are both corresponding to the migration instruction, which can effectively migrate the database connected to the application from the source database to the target database, realizing the automatic synchronous migration of the application's source code project package. Compared with manual migration, it can reduce the time spent in the source code migration process, thereby improving development efficiency. In addition, it can also improve the accuracy of source code migration and ensure the quality of source code migration.

[0111] Additionally, refer to Figure 9 , Figure 9 The hardware structure of an electronic device according to another embodiment is illustrated. The electronic device includes:

[0112] The processor 901 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application.

[0113] The memory 902 can be implemented as a read-only memory (ROM), static storage device, dynamic storage device, or random access memory (RAM). The memory 902 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 902 and is called and executed by the processor 901 using the application migration method of the embodiments of this application, for example, executing the method described above. Figure 1 Method steps S110 to S140, Figure 2 Method steps S210 to S240, Figure 3 Method steps S310 to S330, Figure 4 Method steps S410 to S420 in the text Figure 5 Method steps S510 to S540 in the text Figure 6 Method steps S610 to S630 in the text Figure 7 Method steps S710 to S730;

[0114] The input / output interface 903 is used to implement information input and output;

[0115] The communication interface 904 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).

[0116] Bus 905 transmits information between various components of the device (e.g., processor 901, memory 902, input / output interface 903, and communication interface 904);

[0117] The processor 901, memory 902, input / output interface 903, and communication interface 904 are connected to each other within the device via bus 905.

[0118] This application also provides a storage medium, which is a computer-readable storage medium for computer-readable storage. The storage medium stores one or more programs, which can be executed by one or more processors to implement the above-described application migration method, for example, executing the above-described... Figure 1 Method steps S110 to S140, Figure 2 Method steps S210 to S240, Figure 3 Method steps S310 to S330, Figure 4 Method steps S410 to S420 in the text Figure 5 Method steps S510 to S540 in the text Figure 6 Method steps S610 to S630 in the text Figure 7 Method steps S710 to S730.

[0119] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0120] The application migration method, apparatus, device, and storage medium provided in this application embodiment receive a migration instruction; in response to the migration instruction, obtain the application's source code project package, wherein the source code project package includes multiple source code files, and the migration instruction is used to instruct the migration of the database connected to the application from a source database to a target database; perform matching processing on the source code files using a preset target matching model to match the file to be processed among the multiple source code files, wherein the target matching model corresponds to the migration instruction; and perform modification processing on the file to be processed using preset target modification rules to obtain a modified file to update the source code project package, wherein the target modification rules correspond to the migration instruction. Based on this, upon receiving a migration instruction, the database connected to the application needs to be migrated. During the migration process, a target matching model is used to match the files to be modified in the source code files. Then, the target modification rules are used to modify the files to obtain the modified files, thereby updating the source code project package. Both the target matching model and the target modification rules correspond to the migration instruction, which can effectively migrate the database connected to the application from the source database to the target database. This achieves automatic synchronous migration of the application's source code project package. Compared with manual migration, it can reduce the time spent on the source code migration process, thereby improving development efficiency. In addition, it can also improve the accuracy of source code migration and ensure the quality of source code migration.

[0121] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.

[0122] It will be understood by those skilled in the art that Figures 1 to 7 The technical solutions shown do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.

[0123] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0124] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.

[0125] The terms "first," "second," "third," "fourth," etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0126] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

[0127] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0128] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0129] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0130] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0131] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.< / dbusername> < / dbusername>

Claims

1. An application migration method, characterized in that, include: Receive migration instructions; In response to the migration instruction, the source code project package of the application is obtained, wherein the source code project package includes multiple source code files, and the migration instruction is used to instruct the database to which the application is connected to be migrated from the source database to the target database; The source code files are matched using a preset target matching model to identify the files to be processed from multiple source code files. The target matching model corresponds to the migration instruction and is a regular expression engine, which is configured with multiple configuration regular expressions and SQL regular expressions. The file to be processed is modified using preset target modification rules to obtain modified files, which are then used to update the source code project package. The target modification rules correspond to the migration instructions and include configuration conversion rules and SQL conversion rules. The step of using a preset target matching model to match the source code files, and matching the file to be processed among multiple source code files, includes: The text in the source code file is matched and processed according to the configured regular expression and the SQL regular expression; For any of the aforementioned source code files, when the text within the source code file matches any of the aforementioned configuration regular expressions, it is determined that the source code file contains configuration text to be converted, wherein the configuration text to be converted refers to the text within the source code file that matches the configuration regular expression, and the configuration text to be converted corresponds to the source database; For any of the aforementioned source code files, when the text within the source code file matches any of the aforementioned SQL regular expressions, it is determined that the source code file contains SQL text to be converted, wherein the SQL text to be converted refers to the text within the source code file that matches the SQL regular expression, and the SQL text to be converted corresponds to the source database; Among the multiple source code files, the source code file containing the configuration text to be converted or the SQL text to be converted is used as the file to be processed; The step of modifying the file to be processed using preset target modification rules to obtain a modified file includes: When the file to be processed contains the configuration text to be converted, the configuration text to be converted is processed using the configuration conversion rules to obtain the target configuration text, and the file to be processed is modified according to the target configuration text, wherein the target configuration text corresponds to the target database; When the file to be processed contains the SQL text to be converted, the SQL text to be converted is processed using the SQL conversion rules to obtain the target SQL text, and the file to be processed is modified according to the target SQL text, wherein the target SQL text corresponds to the target database; Based on the modified file to be processed, the modified file is obtained.

2. The method according to claim 1, characterized in that, After the step of obtaining the modified file based on the modified file to be processed, the method further includes: Based on the modification file and the source code project package, modification path information and modification location information are determined, wherein the modification path information is used to indicate the path of the modification file in the source code project package, and the modification location information is used to indicate the location of the target configuration text or the target SQL text within the modification file; A record report is generated based on the filename of the modified file, the modification path information, and the modification location information.

3. The method according to claim 2, characterized in that, Before the step of obtaining the modified file based on the modified file to be processed, the method further includes: Detect whether a configuration modification request for the target configuration text has been received; Upon receiving the configuration modification request, the target configuration text is modified according to the configuration modification request, and the file to be processed is modified according to the modified target configuration text; Detect whether an SQL modification request for the target SQL text has been received; Upon receiving the SQL modification request, the target SQL text is modified according to the SQL modification request, and the file to be processed is modified according to the modified target SQL text.

4. The method according to claim 1, characterized in that, The target matching model is configured with multiple main matching rules and several auxiliary matching rules, wherein the auxiliary matching rules correspond to the main matching rules; the process of matching the source code files using the preset target matching model to identify the file to be processed from the multiple source code files includes: The source code file is input into the target matching model, and the source code file is processed for matching. Traverse the main matching rule, and among the multiple source code files, use the source code files that conform to the main matching rule as intermediate files, and determine whether the main matching rule corresponds to an auxiliary matching rule; When the main matching rule corresponds to an auxiliary matching rule, and the intermediate file conforms to the auxiliary matching rule, the intermediate file is treated as a file to be processed.

5. The method according to claim 1, characterized in that, The target matching model is obtained through the following steps: Perform a difference analysis on the source database and the target database to determine the difference information; Feature extraction is performed on the difference information to determine multiple pattern features; Based on the pattern features, determine the feature regular expression corresponding to the pattern features, and obtain the target matching model based on the feature regular expression.

6. An application migration device, characterized in that, The application migration apparatus is used to implement the application migration method according to any one of claims 1 to 5, and the application migration apparatus includes: The receiving unit is used to receive migration instructions; The acquisition unit is configured to acquire the source code project package of the application in response to the migration instruction, wherein the source code project package includes multiple source code files, and the migration instruction is configured to instruct the database to which the application is connected to be migrated from the source database to the target database. A matching unit is used to perform matching processing on the source code files using a preset target matching model, and to match the file to be processed in multiple source code files. The migration instruction is used to indicate the source database and target database corresponding to the application, and the target matching model corresponds to the migration instruction. The modification unit is used to modify the file to be processed using a preset target modification rule to obtain a modified file, which updates the source code project package, wherein the target modification rule corresponds to the migration instruction.

7. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the application migration method as described in any one of claims 1 to 5.

8. A storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the application migration method as described in any one of claims 1 to 5.