Database migration post-application modification method and device, electronic equipment and storage medium
By supporting automated code scanning and syntax conversion in both local and remote scanning modes, the problem of low efficiency and poor compatibility in application transformation after database migration is solved, achieving efficient and accurate application transformation after database migration.
Patent Information
- Application Number
- CN202611386046.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-08
- Publication Date
- 2026-11-24
AI Technical Summary
In existing technologies, the efficiency and compatibility of application transformation after database migration are low, mainly because manually specifying scanning code and modifying anomalies are inefficient and cannot guarantee accuracy.
This paper provides a method for transforming applications after database migration. By obtaining the target scanning mode and scanning permission parameters selected by the user, it supports local and remote scanning modes, verifies the scanned code, and automatically filters and transforms the code according to file format and syntax conversion rules to achieve the transformation of applications after database migration.
It improves the efficiency and compatibility of application transformation after database migration. Through automated scanning and syntax conversion, it reduces the workload of manual verification, eliminates the possibility of scanning invalid comments, and improves detection accuracy and compatibility.
Smart Images

Figure CN123157690A_ABST
Abstract
Description
Technical Field
[0001] This application relates to database technology, and more particularly to a method, apparatus, electronic device, and storage medium for application modification after database migration. Background Technology
[0002] With the development of databases, database migration has become a core requirement in many fields. After database migration, application adaptation and rewriting is a crucial step.
[0003] In existing technologies, the transformation of applications after database migration usually requires manual specification of scanning code and modification of anomalies.
[0004] However, manually specifying scanning codes and making abnormal modifications is inefficient and cannot guarantee accuracy, resulting in low efficiency and poor compatibility in application transformation after database migration. Summary of the Invention
[0005] This application provides a method, apparatus, electronic device, and storage medium for application modification after database migration, so as to improve the efficiency and compatibility of application modification after database migration.
[0006] In a first aspect, embodiments of this application provide a method for application modification after database migration, the method comprising: Obtain the target scan mode and scan permission parameters of the application to be modified in the Git repository selected by the user, and verify the scan permission parameters in response to the target scan mode; the target scan mode includes local scan mode and remote scan mode; If the verification passes, the code to be modified will be scanned according to the target scanning mode to obtain the file to be converted; Based on the file format of the file to be converted, determine the target comment filtering rules, and filter the code in the file to be converted according to the target comment filtering rules to obtain the code to be converted; Based on the syntax transformation rules of database migration, the code to be transformed is syntax transformed to obtain the target code, enabling application modification after database migration.
[0007] Secondly, embodiments of this application also provide an application modification apparatus after database migration, the application modification apparatus after database migration includes: The scan permission parameter verification module is used to obtain the target scan mode and scan permission parameters of the code to be modified in the Git repository selected by the user, and to verify the scan permission parameters in response to the target scan mode; the target scan mode includes local scan mode and remote scan mode. The module for determining the file to be converted is used to scan the code to be modified according to the target scanning mode and obtain the file to be converted if the verification passes. The module for determining the code to be converted is used to determine the target comment filtering rules based on the file format of the file to be converted, and then filter the code in the file to be converted according to the target comment filtering rules to obtain the code to be converted. The target code determination module is used to perform syntax transformation on the code to be transformed according to the syntax transformation rules of database migration, so as to obtain the target code and realize the application transformation after database migration.
[0008] Thirdly, embodiments of this application also provide an electronic device, which includes: One or more processors; Storage device for storing one or more programs; When one or more programs are executed by one or more processors, the one or more processors implement any of the database migration and application modification methods provided in the embodiments of this application.
[0009] Fourthly, embodiments of this application also provide a storage medium including computer-executable instructions, which, when executed by a computer processor, are used to perform any of the database migration and application modification methods provided in embodiments of this application.
[0010] Fifthly, embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements any of the database migration and application modification methods provided in embodiments of this application.
[0011] This application obtains the target scanning mode and scanning permission parameters of the code to be modified in the Git repository of the application to be modified, selected by the user, and verifies the scanning permission parameters in response to the target scanning mode. The target scanning modes include local scanning mode and remote scanning mode. By providing two target scanning modes and simultaneously supporting both local and remote Git repositories, it achieves comprehensive scenario coverage, breaks through the limitations of existing tools with a single scanning mode, and can meet the needs of different environments without switching tools, greatly improving its feasibility. If the verification passes, the code to be modified is scanned according to the target scanning mode to obtain the file to be converted. Based on the file format of the file to be converted, the target comment filtering rules are determined, and the code in the file to be converted is filtered according to the target comment filtering rules to obtain the code to be converted, eliminating invalid comments from being scanned, significantly improving detection accuracy, greatly reducing the workload of manual verification and rectification, and improving the efficiency of code modification. According to the syntax conversion rules of database migration, the code to be converted is syntax converted to obtain the target code, realizing the application modification after database migration. Automatic conversion through syntax conversion rules improves the compatibility of database migration. Therefore, the technical solution of this application solves the problem that manual specification of scanning code and abnormal modification are inefficient and cannot guarantee accuracy, resulting in low efficiency and poor compatibility of application transformation after database migration, and achieves the effect of improving the efficiency and compatibility of application transformation after database migration. Attached Figure Description
[0012] Figure 1 This is a flowchart of a database migration and application modification method according to Embodiment 1 of this application; Figure 2 This is a flowchart of a database migration and application modification method according to Embodiment 2 of this application; Figure 3 This is a flowchart of a database migration and application modification method according to Embodiment 3 of this application; Figure 4 This is a schematic diagram of the structure of a database migration and application modification device according to Embodiment 4 of this application; Figure 5 This is a schematic diagram of the structure of an electronic device according to Embodiment 5 of this application. Detailed Implementation
[0013] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0014] It should be noted that the terms "first" and "second," etc., in the specification, claims, 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.
[0015] Example 1 Figure 1 This is a flowchart of a database migration application transformation method provided in Embodiment 1 of this application. This embodiment can be applied to the case of automated scanning and adaptation rewriting of applications after database migration. The method can be executed by a database migration application transformation device, which can be implemented in software and / or hardware and specifically configured in a code hosting carrier, such as a Git repository.
[0016] See Figure 1 The database migration and application transformation method shown includes the following steps: S110. Obtain the target scanning mode and scanning permission parameters of the code to be modified in the Git repository selected by the user, and verify the scanning permission parameters in response to the target scanning mode; the target scanning mode includes local scanning mode and remote scanning mode.
[0017] Git repositories are a mainstream platform for code hosting. The application to be modified is the application that requires program modification. The code to be modified is the code corresponding to the application to be modified; it is the core database within the Git repository, and its modification is a crucial part of the database migration. The code to be modified is stored in the Git repository, and its automated scanning and adaptation rewriting are key steps in the database migration process.
[0018] The target scanning mode is a user-selectable mode for scanning the code to be modified. For example, the target scanning mode can include local scanning mode and remote scanning mode. It supports both local Git repository and remote Git repository scanning modes, adapting to all scenarios such as intranet isolation, external network connectivity, local debugging, and offline detection. It breaks through the limitations of existing tools with a single scanning mode, meeting the needs of different environments without switching tools, and greatly improving its practicality.
[0019] Scan permission parameters are the permission parameters required when scanning the code to be modified, used to obtain the files to be converted. For example, scan permission parameters may include repository address, scan branch, account, username, and access token. Different target scan modes may correspond to different scan permission parameters, and this application does not specifically limit this. Validating the scan permission parameters can verify the correctness and validity of the scan permission parameters entered by the user, such as verifying the existence of the path and the validity of the access token.
[0020] Users can select the target scanning mode for the Git repository containing the code to be modified through the front-end web interface. They then fill in the corresponding scan permission parameters in the displayed authentication parameters. The backend verifies these parameters based on the target scanning mode. When the target scanning mode is local, remote authentication parameters (remote repository address, scanned branch, account, and access token, etc.) are automatically hidden, only displaying the local Git repository physical path input box. The backend automatically verifies the path's existence and whether it contains a .git directory, only initiating the scan after confirming it's a legitimate Git repository, preventing scans of invalid paths. When the target scanning mode is remote, the local path input box is automatically hidden, displaying the four required input fields: remote repository address, scanned branch, username, and access token. The remote scan process begins after permission parameter verification. During target scanning mode switching, the scan status can be automatically reset, historical data and error messages cleared, avoiding runtime failures caused by parameter confusion between different modes.
[0021] Optionally, verifying scan permission parameters can include Git parameter verification, authentication verification, repository verification, and local path verification, and generate exception prompts based on the verification results.
[0022] Git parameter validation can include identifying parameter errors such as exit code 129 and unknown option, and providing error messages such as prompts for the original command format and guidance on parameter correction.
[0023] Authentication verification can include identifying insufficient permissions, invalid tokens, and incorrect usernames, while error messages can include verifying account permissions and token access scope.
[0024] Repository verification can include identifying non-existent branches and incorrect repository addresses, and error messages can include verifying the repository path and branch name.
[0025] Local path verification can include identifying non-existent paths and non-Git repositories, and exception messages can include verifying the integrity of local paths and .git directories.
[0026] While verifying the scanning permission parameters, it can also perform network anomaly verification: identify connection timeouts, domain name resolution failures, and port failures, and provide anomaly prompts including checking VPN, proxy configuration, and replacing internal network IPs.
[0027] By scanning permission parameters for verification, targeted solutions are output for each type of anomaly, reducing the difficulty of operation, maintenance, and troubleshooting.
[0028] S120. If the verification passes, the code to be modified will be scanned according to the target scanning mode to obtain the file to be converted.
[0029] If the verification passes, meaning the scan permission parameters corresponding to the target scan mode are validated, scanning can begin. The file to be converted can be the file generated from the scan results of the code to be modified, used to determine the code to be converted. Different target scan modes correspond to different scanning methods. For example, when the target scan mode is local scanning, the file corresponding to the code to be modified in a valid local Git repository can be read directly, achieving efficient local scanning and obtaining the file to be converted. For example, when the target scan mode is remote scanning, the file corresponding to the code to be modified in the relevant Git repository can be remotely cloned using native Git commands to obtain the file to be converted.
[0030] S130. Based on the file format of the file to be converted, determine the target comment filtering rules, and filter the code in the file to be converted according to the target comment filtering rules to obtain the code to be converted.
[0031] The target comment filtering rules can be customized for different code file formats. These rules are used to filter code comments in the file to be converted, resulting in the code to be converted. The code to be converted is the code obtained after filtering the code comments in the file to be converted. This code is used to obtain the target code and rewrite the application code after database migration. For example, based on the file format of the file to be converted, the target comment filtering rules can be determined as follows: distinguishing between SQL, Java, Python, XML, and JSP file formats, the target comment filtering rules can be set to filter single-line comments (--, #, / / ) or multi-line nested comments ( / * * / , ...).<!-- --> Comments enclosed in triple quotes are removed, and only valid business code lines are retained for detection, completely avoiding the problem of mis-scanning comment content.
[0032] S140. According to the syntax conversion rules of database migration, perform syntax conversion on the code to be converted to obtain the target code and realize the application transformation after database migration.
[0033] Syntax conversion rules are used to transform different syntaxes, converting the code to be converted into target code. The target code is the code that the code to be converted conforms to the syntax rules of the target database. For example, based on the incompatible parts between the code to be converted and the target database, a pre-defined regular expression library can be used to perform syntax conversion on the code to be converted, obtaining the target code, thus enabling application modification after database migration. The regular expression library supports dynamic expansion, allowing the addition of new syntax types without modifying the core matching logic.
[0034] For example, when the code to be converted is DB2 and the target database's syntax type is MySQL, 10 core syntax conversion regular expression rules can be preset, covering DB2-specific syntax such as auto-increment column definitions, pseudo-table queries, pagination syntax, date functions, string concatenation, join updates, merge inserts, and isolation levels, covering mainstream migration scenarios. Table 1 shows one type of syntax conversion regular expression rule table.
[0035] Table 1. Regular expression rules for syntax transformation It should be noted that all information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) involved in this disclosure are information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data comply with the relevant laws, regulations and standards of the relevant regions.
[0036] The technical solution of this embodiment obtains the target scanning mode and scanning permission parameters of the code to be modified in the Git repository selected by the user, and verifies the scanning permission parameters in response to the target scanning mode. The target scanning mode includes a local scanning mode and a remote scanning mode. By providing two target scanning modes and simultaneously supporting both local and remote Git repositories, it achieves comprehensive scenario coverage, breaks through the limitations of the single scanning mode of existing tools, and can meet the needs of different environments without switching tools, greatly improving its feasibility. If the verification passes, the code to be modified is scanned according to the target scanning mode to obtain the file to be converted. According to the file format of the file to be converted, the target comment filtering rules are determined, and the code in the file to be converted is filtered according to the target comment filtering rules to obtain the code to be converted. This eliminates invalid comments from being scanned, significantly improves the detection accuracy, greatly reduces the workload of manual verification and rectification, and improves the efficiency of code modification. According to the syntax conversion rules of database migration, the code to be converted is syntax converted to obtain the target code, realizing the application modification after database migration. Automatic conversion is performed through syntax conversion rules to improve the compatibility of database migration. Therefore, the technical solution of this application solves the problem that manual specification of scanning code and abnormal modification are inefficient and cannot guarantee accuracy, resulting in low efficiency and poor compatibility of application transformation after database migration, and achieves the effect of improving the efficiency and compatibility of application transformation after database migration.
[0037] Example 2 Figure 2 This is a flowchart of a database migration and application transformation method provided in Embodiment 2 of this application. The technical solution of this embodiment is further refined based on the above technical solution.
[0038] Furthermore, the statement "based on the syntax conversion rules of database migration, perform syntax conversion on the code to be converted to obtain the target code and realize the application transformation after database migration" is refined into: "based on the syntax conversion rules of database migration, perform compatibility testing on the code to be converted; if the compatibility test result is incompatible, determine whether to perform automatic correction based on the security level of the incompatible exception code; if so, replace the exception segment based on the line number of the exception code to obtain the target code and realize the application transformation after database migration," in order to realize the application transformation after database migration.
[0039] See Figure 2 The method for application transformation after database migration, as shown, includes: S210. Obtain the target scanning mode and scanning permission parameters of the code to be modified in the Git repository selected by the user, and verify the scanning permission parameters in response to the target scanning mode; the target scanning mode includes local scanning mode and remote scanning mode.
[0040] S220. If the verification passes, the code to be modified will be scanned according to the target scanning mode to obtain the file to be converted.
[0041] S230. Based on the file format of the file to be converted, determine the target comment filtering rules, and filter the code in the file to be converted according to the target comment filtering rules to obtain the code to be converted.
[0042] S240. Perform compatibility testing on the code to be converted according to the syntax conversion rules of database migration.
[0043] Compatibility testing checks whether the code to be converted is syntactically compatible with the target database, determining whether automatic correction should be performed. Compatibility testing can be performed according to pre-defined rules. For example, these rules might include: ignoring case sensitivity and inline limits; non-greedy inline matching that does not cross lines, exceed boundaries, or pollute the context; adaptive matching with spaces, indentation, and newlines; and performing compatibility testing only on valid business logic, skipping comment lines and blank lines.
[0044] S250. If the compatibility test result is incompatible, determine whether to perform automatic correction based on the security level of the incompatible exception code.
[0045] If the compatibility test result indicates incompatibility, the incompatible code to be converted needs to be replaced to ensure the compatibility of the application code after database migration. The exception code can be incompatible code. The security level can be the security level of the exception code, used to determine the correction method. For example, the security level can be determined based on the importance level of the data in the exception code. For instance, if the data in the exception code has a high importance level, a higher security level is determined, and with a high security level, automatic correction is not performed to avoid data leakage and potential data security risks.
[0046] Optionally, when performing compatibility testing, matching priorities can be sorted by migration risk, modification cost, and frequency of occurrence.
[0047] For example, the matching priority order can be as follows: 1) High priority (must be modified): pseudo-tables, pagination syntax, auto-increment columns, and MERGE INTO; 2) Medium priority (high-frequency modification): string concatenation, date functions, and system tables; 3) Low priority (scenario-based modification): transaction isolation level and special functions.
[0048] Compatibility checks are performed sequentially, stopping once a match is found, to avoid duplicate reporting of the same line.
[0049] In one optional embodiment, if the compatibility test result is incompatible, then based on the security level of the incompatible exception code, it is determined whether to perform automatic correction, including: if the compatibility test result is incompatible, then based on whether the code of the incompatible exception code contains business data, it is determined whether to perform automatic correction; based on the security level of the exception code, it is determined whether to perform automatic correction.
[0050] Business data can be business-related data used to determine whether automatic correction should be performed. When the abnormal code contains business data, the security level of the abnormal code can be determined to be high. When the security level is high, automatic correction is not performed to protect the privacy and security of business data. For example, when the abnormal code contains business data, a pop-up prompt can be automatically displayed, requiring user confirmation before automatic correction is performed. This ultimately achieves fully automatic transformation of low-risk syntax and manual confirmation of high-risk syntax, significantly improving application transformation efficiency while ensuring business security.
[0051] When the abnormal code does not contain business data, it can be automatically corrected, with automatic code replacement, automatic saving, automatic Git commit, and automatic push, providing fully automated code correction capabilities.
[0052] If the compatibility test result is incompatible, the security level of the incompatible exception code is determined based on whether the code contains business data. Based on the security level of the exception code, it is determined whether to perform automatic correction. Differentiated correction strategies are executed based on whether the syntax involves business data, which greatly improves the efficiency of application transformation while ensuring business security.
[0053] S260. If so, then based on the line number of the exception code, perform exception segment replacement to obtain the target code and realize application transformation after database migration.
[0054] If so, meaning automatic correction is confirmed, then based on the line number of the exception code, the exception fragment is replaced to obtain the target code, enabling application transformation after database migration. Exception fragment replacement requires no business understanding, does not affect data logic, and is purely a syntax replacement. For example, when converting code type from DB2 to MySQL, an example of exception fragment replacement could be as follows: sysibm.sysdummy1→dual FETCH FIRST N ROWS ONLY→LIMIT || String concatenation → CONCAT() CURRENT DATE → CURDATE() CURRENT TIMESTAMP→NOW() WITH UR Isolation Level → Remove SYSCAT system tables → information_schema Specifically, the steps for replacing abnormal fragments can be as follows: 1) File opening and encoding security: Open the target code file securely with UTF-8 encoding to avoid garbled characters and file corruption.
[0055] 2) Line-level precise replacement: Based on the line number matched by the regular expression, only incompatible segments are replaced without modifying other code.
[0056] 3) Syntax validation after replacement: After the replacement is completed, the system checks the integrity of the SQL syntax to ensure that there are no broken sentences, missing characters, or errors.
[0057] 4) Automatic file saving: Overwrite the original file to obtain the target code.
[0058] In an optional embodiment, if the compatibility test result is incompatible, after determining whether to perform automatic correction based on the security level of the abnormal code, the method further includes: if not, performing a modification query, and in response to the query result of the modification query, converting the code to be converted to obtain the target code, thereby realizing the application transformation after database migration.
[0059] If not, meaning automatic correction is not performed, a modification query is required. The modification query asks the user whether to perform automatic modification to determine the modification method. The query result can include confirming the modification or not modifying for now. In response to the modification query result, the code to be converted undergoes appropriate syntax conversion to obtain the target code, enabling application transformation after database migration.
[0060] The modification prompt can be a manual confirmation prompt. For example, a manual confirmation prompt can be an automatically pop-up dialog box on the front end, and the prompt content can include: file path, line number, original DB statement, recommended MySQL syntax, and risk warning. For instance, the manual confirmation prompt could be: "This statement involves business data; please confirm whether to modify it." The user's selection is obtained as the prompt result. If the user selects to confirm the modification, the replacement is executed; if the user selects not to modify, the process is skipped and logged. Finally, all modification records are archived.
[0061] If the query fails, a modification query is initiated, and in response to the query result, the code to be transformed is converted to obtain the target code. This enables application transformation after database migration and ensures the security of business data.
[0062] Optionally, after obtaining the target code, the target code can be automatically submitted and pushed to achieve database migration.
[0063] The automatic submission and push of target code can include the following steps: 1) Git status detection: Automatically determines whether a file has been modified and whether it belongs to the current repository.
[0064] 2) Automatic addition: Execute `git add <target file>` to add the corrected file to the staging area.
[0065] 3) Automatic commit: The standardized format for commit information is [DB2→MySQL Automatic Correction] file: xxx.java, correction syntax: sysdummy1→dual.
[0066] 4) Automatic push: Pushes changes to the remote Git repository.
[0067] 5) Commit log records: records the submitter, commit time, modified files, number of modified lines, syntax type, and commit result.
[0068] 6) Abnormal fallback: If the submission fails (network error, insufficient permissions), it will automatically retry twice. If it still fails, it will be recorded and the user will be notified.
[0069] The technical solution of this embodiment performs compatibility testing on the code to be converted according to the syntax conversion rules of database migration. If the compatibility test result is incompatible, it determines whether to perform automatic correction based on the security level of the incompatible abnormal code. A differentiated correction strategy is executed according to the security level to improve the efficiency of the transformation while ensuring code security. If the result is incompatible, the abnormal segment is replaced according to the line number of the abnormal code to obtain the target code, realize the application transformation after database migration, provide fully automatic code correction, reduce manual modification, and improve code conversion efficiency.
[0070] Example 3 Figure 3 This is a flowchart of a database migration and application transformation method provided in Embodiment 3 of this application. The technical solution of this embodiment is further refined based on the above technical solution.
[0071] Furthermore, the statement "If the verification passes, then scan the code to be modified according to the target scanning mode to obtain the file to be converted" is refined to: "If the verification passes, then determine whether the target scanning mode is the local scanning mode; if so, then scan the code to be modified according to the preset target scan file type to obtain the file to be converted" to obtain the file to be converted.
[0072] See Figure 3 The method for application transformation after database migration, as shown, includes: S310. Obtain the target scanning mode and scanning permission parameters of the code to be modified in the Git repository selected by the user, and verify the scanning permission parameters in response to the target scanning mode; the target scanning mode includes local scanning mode and remote scanning mode.
[0073] S320. If the verification passes, determine whether the target scanning mode is the local scanning mode.
[0074] If the verification passes, read the target scanning mode and determine whether the target scanning mode is the local scanning mode.
[0075] S330. If so, then scan the code to be modified according to the preset target scan file type to obtain the file to be converted.
[0076] If so, meaning the target scanning mode is local scanning mode, then the code to be modified is scanned according to the preset target scan file type to obtain the file to be converted. Specifically, this may include the following steps: This feature enables lossless scanning of local Git repositories without requiring a network connection or cloning. It directly reads legitimate Git repository files locally, achieving efficient local scanning. For example, it allows for targeted file type scanning: a pre-defined whitelist of target file extensions is used to scan only .sql, .java, .py, .xml, .jsp, and .properties files, skipping non-target files and significantly improving scanning efficiency while reducing invalid detections.
[0077] Optionally, when the target scanning mode is local scanning mode, path validity verification and redundant directory filtering can be performed.
[0078] Path validity verification can be performed using a double check: first, it checks if the local physical path exists, and then it checks if the path contains a hidden `.git` directory, filtering out non-Git repository paths and avoiding invalid scans. Redundant directory filtering can automatically skip the `.git` version control directory, avoiding scanning redundant Git version-related files and log files, and only scanning business code files, thus improving scanning efficiency.
[0079] In an optional embodiment, after determining whether the target scanning mode is a local scanning mode if the verification passes, the method further includes: if not, determining the target network adaptation method from the candidate network adaptation methods based on the current network conditions; connecting to the remote database through the target network adaptation method, and scanning the database to be migrated through the native cloning command to obtain the file to be converted.
[0080] If not, meaning the target scanning mode is remote scanning mode. Candidate network adaptation methods can include built-in proxy environment variable configuration adaptation, Hosts mapping adaptation, and internal IP replacement adaptation. The target network adaptation method can be determined as follows: Prioritize built-in proxy adaptation, primarily suitable for scenarios where enterprise internal networks need to access the GitLab server through a proxy service. This involves setting environment variables such as `http_proxy`, `https_proxy`, and `no_proxy` to force Git to use a proxy to access the GitLab server. When the proxy solution fails (e.g., no proxy is available or the proxy does not support internal domain names), the system automatically resolves the internal IP corresponding to the GitLab domain name for access. If a connection still cannot be established after IP mapping (e.g., the port is blocked by a firewall), then directly replace the internal IP with the adaptation, and the URL is automatically rewritten: rewriting `http: / / gitlab.example.com / xxx.git` to `http: / / 192.168.xx / xxx.git` for access, resolving issues such as domain name resolution failures, port inaccessibility, or network isolation for enterprise internal GitLab private repositories.
[0081] Optionally, a 30-second command execution timeout threshold can be set, which will automatically terminate the process after the timeout. At the same time, the empty temporary directory will be automatically cleaned up after the scan is completed to avoid server resource consumption and file redundancy.
[0082] The native cloning command abandons the traditional GitPython wrapper call method and uses subprocess to natively call Git commands, allowing for completely independent concatenation of standard Git native parameters and thoroughly avoiding version compatibility and parameter conflict issues. The solidified cloning command: `git clone --branch branch --depth 1 --quiet --no-tags authentication address temporary directory` retains only the core parameters compatible with all Git versions, without any redundant or hidden parameters, fundamentally solving the exit code 129 parameter error problem. Furthermore, it uses urllib.parse to URL-encode and escape special characters (@, :, / , and &, etc.) in usernames and access tokens, resolving authentication failures caused by special characters.
[0083] If the network fails, the target network adaptation method is determined from the candidate network adaptation methods based on the current network conditions, thus achieving a fallback network adaptation. The target network adaptation method is then connected to a remote database, and the codebase to be modified is scanned using native cloning commands to obtain the files to be converted, thereby achieving remote scanning and completely avoiding version compatibility and parameter conflict issues.
[0084] After scanning, only the final generated CSV scan report is retained; all process files and temporary files are automatically cleaned up, achieving "archiveable results and traceless process." Before automatic cleanup, the validity of temporary directories is verified, and the target cleanup path undergoes double verification to confirm the directory's existence and its legitimacy as a temporary directory generated during the scan. Unauthorized cleanup is prohibited, ensuring system security. Deep cleanup of remote cloned directories is performed for remote Git repository scanning modes. After the scan completes or terminates abnormally, the cloned temporary directories are immediately and recursively deleted, thoroughly cleaning code files, Git version files, indexes, and logs, leaving no code residue.
[0085] Optionally, a fallback mechanism for abnormal scenarios is also included. When network anomalies, permission anomalies, parameter anomalies, or command anomalies occur, the fallback mechanism is automatically triggered to forcibly reclaim resources and ensure server stability.
[0086] S340. Based on the file format of the file to be converted, determine the target comment filtering rules, and filter the code in the file to be converted according to the target comment filtering rules to obtain the code to be converted.
[0087] S350. According to the syntax transformation rules of database migration, perform syntax transformation on the code to be transformed to obtain the target code and realize the application transformation after database migration.
[0088] The technical solution of this embodiment determines whether the target scanning mode is a local scanning mode if the verification passes; if so, it scans the code to be modified according to the preset target scanning file type to obtain the file to be converted. Based on the target scanning file type, it realizes fast local scanning, skips invalid files, and improves scanning efficiency.
[0089] Example 4 Figure 4 The diagram shown is a structural schematic of an application modification device after database migration provided in Embodiment 4 of this application. This embodiment is applicable to the automatic scanning and adaptation rewriting of the syntax of applications after database migration. The specific structure of the application modification device after database migration is as follows: The scan permission parameter verification module 410 is used to obtain the target scan mode and scan permission parameters of the code to be modified in the Git repository of the application to be modified selected by the user, and to verify the scan permission parameters in response to the target scan mode; the target scan mode includes local scan mode and remote scan mode. The file to be converted module 420 is used to scan the code to be modified according to the target scanning mode to obtain the file to be converted if the verification passes. The code to be converted module 430 is used to determine the target comment filtering rules according to the file format of the file to be converted, and to filter the code in the file to be converted according to the target comment filtering rules to obtain the code to be converted; The target code determination module 440 is used to perform syntax transformation on the code to be transformed according to the syntax transformation rules of database migration, so as to obtain the target code and realize the application transformation after database migration.
[0090] The technical solution of this embodiment obtains the target scanning mode and scanning permission parameters of the code to be modified in the Git repository selected by the user, and verifies the scanning permission parameters in response to the target scanning mode. The target scanning mode includes a local scanning mode and a remote scanning mode. By providing two target scanning modes and simultaneously supporting both local and remote Git repositories, it achieves comprehensive scenario coverage, breaks through the limitations of the single scanning mode of existing tools, and can meet the needs of different environments without switching tools, greatly improving its feasibility. If the verification passes, the code to be modified is scanned according to the target scanning mode to obtain the file to be converted. According to the file format of the file to be converted, the target comment filtering rules are determined, and the code in the file to be converted is filtered according to the target comment filtering rules to obtain the code to be converted. This eliminates invalid comments from being scanned, significantly improves the detection accuracy, greatly reduces the workload of manual verification and rectification, and improves the efficiency of code modification. According to the syntax conversion rules of database migration, the code to be converted is syntax converted to obtain the target code, realizing the application modification after database migration. Automatic conversion is performed through syntax conversion rules to improve the compatibility of database migration. Therefore, the technical solution of this application solves the problem that manual specification of scanning code and abnormal modification are inefficient and cannot guarantee accuracy, resulting in low efficiency and poor compatibility of application transformation after database migration, and achieves the effect of improving the efficiency and compatibility of application transformation after database migration.
[0091] Optionally, the target code determination module 440 includes: The compatibility detection unit is used to perform compatibility checks on the code to be converted based on the syntax conversion rules of the database migration. An automatic correction judgment unit is used to determine whether to perform automatic correction based on the security level of the incompatible exception code if the compatibility detection result is incompatible. The exception fragment replacement unit is used to replace the exception fragment according to the line number of the exception code if the exception is true, so as to obtain the target code and realize the application transformation after database migration.
[0092] Optionally, the target code determination module 440 also includes: The code to be migrated conversion unit is used to perform a modification query if no, and in response to the query result, convert the code to be converted to obtain the target code, thereby realizing the application transformation after database migration.
[0093] Optional, the automatic correction judgment unit includes: The security level determination subunit is used to determine the security level of the abnormal code based on whether the code contains business data if the compatibility test result is incompatible. The automatic correction determination subunit is used to determine whether to perform automatic correction based on the security level of the exception code.
[0094] Optionally, the file to be converted determination module 420 includes: The local scanning mode determination unit is used to determine whether the target scanning mode is the local scanning mode if the verification passes. The database scanning unit to be migrated is used to scan the code to be modified according to the preset target scan file type to obtain the file to be converted.
[0095] Optionally, the file to be converted determination module 420 also includes: The target network adaptation method determination unit is used to determine the target network adaptation method from the candidate network adaptation methods based on the current network situation if no. The file to be converted determination unit is used to connect to a remote database via a target network adaptation method and scan the code to be modified using native cloning instructions to obtain the file to be converted.
[0096] The database migration application modification apparatus provided in this application embodiment can execute the database migration application modification method provided in any embodiment of this application, and has the corresponding functional modules and beneficial effects for executing the database migration application modification method.
[0097] According to embodiments of the present invention, the present invention also provides an electronic device, a readable storage medium, and a computer program product.
[0098] Example 5 Figure 5 This is a schematic diagram of the structure of an electronic device provided in Embodiment 5 of this application, as shown below. Figure 5 As shown, the electronic device includes a processor 510, a memory 520, an input device 530, and an output device 540; the number of processors 510 in the electronic device can be one or more. Figure 5 Taking a processor 510 as an example; the processor 510, memory 520, input device 530, and output device 540 in the electronic device can be connected via a bus or other means. Figure 5 Taking the example of a connection between China and Israel via a bus.
[0099] The memory 520, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and modules, such as the program instructions / modules corresponding to the database migration and application modification method in this embodiment (e.g., the scanning permission parameter verification module 410, the file to be converted determination module 420, the code to be converted determination module 430, and the target code determination module 440). The processor 510 executes various functional applications and data processing of the electronic device by running the software programs, instructions, and modules stored in the memory 520, thereby realizing the above-mentioned database migration and application modification method.
[0100] The memory 520 may primarily include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a given function; the data storage area may store data created based on terminal usage. Furthermore, the memory 520 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 520 may further include memory remotely located relative to the processor 510, which can be connected to the electronic device 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.
[0101] Input device 530 can be used to receive input character information and generate key signal inputs related to user settings and function control of the electronic device. Output device 540 may include display devices such as a display screen.
[0102] Example 6 Embodiment Six of this application also provides a storage medium containing computer-executable instructions. When executed by a computer processor, the computer-executable instructions are used to perform a method for transforming an application after database migration. The method includes: obtaining the target scanning mode and scanning permission parameters of the application to be transformed in a Git repository selected by the user, and verifying the scanning permission parameters in response to the target scanning mode; the target scanning mode includes a local scanning mode and a remote scanning mode; if the verification passes, scanning the code to be transformed according to the target scanning mode to obtain a file to be transformed; determining target comment filtering rules according to the file format of the file to be transformed, and filtering the code in the file to be transformed according to the target comment filtering rules to obtain code to be transformed; performing syntax transformation on the code to be transformed according to the syntax transformation rules of database migration to obtain target code, thereby realizing the transformation of the application after database migration.
[0103] Of course, the computer-executable instructions provided in the embodiments of this application are not limited to the method operations described above, but can also perform related operations in the database migration and application modification method provided in any embodiment of this application.
[0104] Based on the above description of the implementation methods, those skilled in the art can clearly understand that this application can be implemented using software and necessary general-purpose hardware, and of course, it can also be implemented using hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk, or optical disk, etc., including several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0105] It is worth noting that in the embodiments of the above-mentioned database migration device, the various units and modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the scope of protection of this application.
[0106] Note that the above are merely preferred embodiments and the technical principles employed in this application. Those skilled in the art will understand that this application is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of this application. Therefore, although this application has been described in detail through the above embodiments, this application is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of this application, the scope of which is determined by the scope of the appended claims.
Claims
1. A method for application modification after database migration, characterized in that, include: The system obtains the target scanning mode and scanning permission parameters of the code to be modified in the Git repository of the application to be modified, selected by the user, and verifies the scanning permission parameters in response to the target scanning mode; the target scanning mode includes local scanning mode and remote scanning mode. If the verification passes, the code to be modified is scanned according to the target scanning mode to obtain the file to be converted; Based on the file format of the file to be converted, the target comment filtering rules are determined, and the code in the file to be converted is filtered according to the target comment filtering rules to obtain the code to be converted; Based on the syntax transformation rules of database migration, the code to be transformed is syntax transformed to obtain the target code, enabling application modification after database migration.
2. The method according to claim 1, characterized in that, The process involves performing syntax transformation on the code to be transformed according to the syntax transformation rules of database migration to obtain the target code, thereby enabling application modification after database migration. This includes: Based on the syntax transformation rules for database migration, perform compatibility testing on the code to be transformed; If the compatibility test result is incompatible, then determine whether to perform automatic correction based on the security level of the incompatible exception code; If so, the abnormal segment is replaced according to the line number of the abnormal code to obtain the target code, thereby realizing the application transformation after database migration.
3. The method according to claim 2, characterized in that, After determining whether to perform automatic correction based on the security level of the exception code if the compatibility test result is incompatible, the method further includes: If not, a modification query is performed, and in response to the query result, the code to be transformed is transformed to obtain the target code, thereby realizing the application transformation after database migration.
4. The method according to claim 2, characterized in that, If the compatibility test result is incompatible, then based on the security level of the abnormal code, it is determined whether to perform automatic correction, including: If the compatibility test result is incompatible, the security level of the abnormal code is determined based on whether the abnormal code contains business data. Based on the security level of the abnormal code, determine whether to perform automatic correction.
5. The method according to claim 1, characterized in that, If the verification passes, the code to be modified is scanned according to the target scanning mode to obtain the file to be converted, including: If the verification passes, determine whether the target scanning mode is a local scanning mode; If so, the code to be modified is scanned according to the preset target file type to obtain the file to be converted.
6. The method according to claim 5, characterized in that, After determining whether the target scanning mode is a local scanning mode if the verification passes, the method further includes: If not, then determine the target network adaptation method from the candidate network adaptation methods based on the current network conditions; The target network is adapted to connect to a remote database, and the code to be modified is scanned using native cloning commands to obtain the file to be converted.
7. A device for application modification after database migration, characterized in that, include: The scan permission parameter verification module is used to obtain the target scan mode and scan permission parameters of the code to be modified in the Git repository of the application to be modified selected by the user, and to verify the scan permission parameters in response to the target scan mode; the target scan mode includes local scan mode and remote scan mode; The file to be converted module is used to scan the code to be modified according to the target scanning mode if the verification passes, so as to obtain the file to be converted. The code to be converted module is used to determine the target comment filtering rules according to the file format of the file to be converted, and to filter the code in the file to be converted according to the target comment filtering rules to obtain the code to be converted. The target code determination module is used to perform syntax transformation on the code to be transformed according to the syntax transformation rules of database migration, so as to obtain the target code and realize the application transformation after database migration.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the database migration and application modification method as described in any one of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the database migration application modification method as described in any one of claims 1-6.
10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the database migration and application modification method as described in any one of claims 1-6.
