Method, device, storage medium and electronic equipment for switching new and old data tables

CN119046293BActive Publication Date: 2026-09-18BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411042213.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-31
Publication Date
2026-09-18
Estimated Expiration
2044-07-31

AI Technical Summary

Technical Problem

[0003]本申请提供了一种切换新老数据表的方法、装置、存储介质以及电子设备,以解决人工迁移线上业务的数据表的工作效率太低而影响线上业务的正常运行的技术问题

Benefits of technology

[0014]In this embodiment, the following steps are taken: The original data table in the business system is obtained, and a new data table is created based on the structure of the original data table; all program code in the business code of the business system that references the original data table is modified to reference the new data table; a target plugin with encryption/decryption annotations and mapping relationships is added to the business system, so that the business system uses the original data table and skips the encryption/decryption mechanism corresponding to the encryption/decryption annotations during operation. The encryption/decryption annotations are used to mark fields of private data that need to be encrypted/decrypted, and the mapping relationship is a mapping relationship between the new data table and the original data table; all data in the original data table is encrypted and synchronized to the new data table, and after synchronization, the mapping relationship in the target plugin is removed, so that the business system uses the new data table and operates... The above encryption/decryption mechanism achieves its goal by creating a new data table to replace the old one containing privacy data, maintaining a consistent structure between the old and new tables. It also replaces references to the old data table in the business code with the new one, and develops a target plugin for dynamic configuration. The new data table is used based on this configuration, allowing developers flexibility in debugging and switching. Data in both tables is synchronized, and the target plugin's mapping is removed after synchronization. This ensures encrypted storage of privacy data, minimizing the impact on business logic, ensuring business continuity and consistency, meeting privacy protection and compliance requirements, and improving the efficiency of data table migration. Ultimately, this solves the technical problem of low efficiency in manually migrating online business data tables, which hinders the normal operation of online businesses.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119046293B_ABST
    Figure CN119046293B_ABST
Patent Text Reader

Abstract

The application relates to a method and device for switching old and new data tables, a storage medium and electronic equipment. The method comprises the following steps: obtaining an original data table in a business system, and creating a new data table according to the structure of the original data table; modifying all program codes in business codes of the business system, which refer to the original data table, to refer to the new data table; adding a target plug-in with encryption and decryption annotations and mapping relationships in the business system, so that the business system uses the original data table and skips the encryption and decryption mechanism corresponding to the encryption and decryption annotations during operation; synchronizing all data of the original data table to the new data table, and removing the mapping relationships in the target plug-in after synchronization is completed, so that the business system uses the new data table and runs the encryption and decryption mechanism during operation. The application solves the technical problem that the work efficiency of manually migrating the data table of an online business is too low to affect the normal operation of the online business.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of cloud computing technology, and in particular to a method, apparatus, storage medium, and electronic device for switching between old and new data tables. Background Technology

[0002] In today's technological environment, intelligent customer service teams play a crucial role. These services include online services, voice services, and outbound calls, directly serving the public. During these services, it's inevitable to query and record users' personal information, such as phone numbers and email addresses. As customer service operations evolve, their complexity increases. For example, the data related to phone numbers can number in the dozens, involving increasingly complex and difficult-to-manage upper-level logic. Therefore, to protect user privacy and meet compliance requirements, this private information must be stored encrypted. However, completing this compliance transformation in the shortest possible time without disrupting online operations has become a major challenge. Current technical solutions, such as dual-write and system downtime upgrades, cannot meet this requirement. For instance, assuming migrating one table requires two person-days, migrating dozens of tables would require dozens or even hundreds of person-days. Clearly, this is inefficient and could severely impact the normal operation of online services. Summary of the Invention

[0003] This application provides a method, apparatus, storage medium, and electronic device for switching between old and new data tables to solve the technical problem that the low efficiency of manually migrating data tables for online business affects the normal operation of online business.

[0004] Firstly, this application provides a method for switching between old and new data tables, comprising: obtaining the original data table in the business system and creating a new data table based on the structure of the original data table; modifying all program code in the business code of the business system that references the original data table to reference the new data table; adding a target plugin with encryption / decryption annotations and mapping relationships to the business system, so that the business system uses the original data table and skips the encryption / decryption mechanism corresponding to the encryption / decryption annotations during operation, wherein the encryption / decryption annotations are used to mark fields of privacy data that need to be encrypted / decrypted, and the mapping relationship is a mapping relationship between the new data table and the original data table; encrypting and synchronizing all data in the original data table to the new data table, and after synchronization is completed, removing the mapping relationship in the target plugin, so that the business system uses the new data table and runs the encryption / decryption mechanism during operation.

[0005] Secondly, this application provides an apparatus for switching between old and new data tables, comprising: an acquisition module for acquiring the original data table in a business system and creating a new data table based on the structure of the original data table; a modification module for modifying all program code in the business code of the business system that references the original data table to reference the new data table; a first addition module for adding a target plugin with encryption / decryption annotations and mapping relationships to the business system, so that the business system uses the original data table and skips the encryption / decryption mechanism corresponding to the encryption / decryption annotations during operation, wherein the encryption / decryption annotations are used to mark fields of privacy data that need to be encrypted / decrypted, and the mapping relationship is a mapping relationship between the new data table and the original data table; and a first synchronization module for encrypting and synchronizing all data from the original data table to the new data table, and removing the mapping relationship from the target plugin after synchronization, so that the business system uses the new data table and runs the encryption / decryption mechanism during operation.

[0006] As an optional example, the above-mentioned acquisition module includes: a creation unit, used to create an initial data table in the above-mentioned business system, wherein the structure of the initial data table is the same as that of the original data table; and a first modification unit, used to modify the field length of all privacy data in the initial data table to the target length, thereby obtaining the new data table.

[0007] As an optional example, the above modification module includes: a marking unit, used to search and mark all program code in the above business code that references the above original data table; and a second modification unit, used to modify the reference relationship of all the above program code to reference the above new data table.

[0008] As an optional example, the above apparatus further includes: a first creation module for creating a configuration file for the target plugin before adding the target plugin with encryption / decryption annotations and mapping relationships to the business system; a second creation module for creating the encryption / decryption annotations based on the fields of all privacy data in the original data table; a third creation module for creating the mapping relationships based on the original data table and the new data table; and a second adding module for adding the encryption / decryption annotations and mapping relationships to the configuration file.

[0009] As an optional example, the above synchronization module includes: a first synchronization unit, used to encrypt and synchronize all privacy data in the original data table to the new data table; and a second synchronization unit, used to synchronize all data in the original data table except for privacy data to the new data table.

[0010] As an optional example, the above synchronization module includes: a storage unit, used to encrypt all privacy data generated during the operation of the above business system according to the above encryption and decryption mechanism and store it in the corresponding field of the above new data table.

[0011] As an optional example, the above apparatus further includes: a third adding module, configured to add the mapping relationship to the target plugin again after removing the mapping relationship from the target plugin, in the event of an anomaly detected in the business system, so that the business system uses the original data table and skips the encryption / decryption mechanism during operation; a second synchronization module, configured to encrypt and synchronize the incremental data of the original data table to the new data table after the business system has returned to normal for a target duration; and a removal module, configured to remove the mapping relationship so that the business system uses the new data table and runs the encryption / decryption mechanism during operation.

[0012] Thirdly, this application provides a storage medium storing a computer program, wherein the computer program is executed by a processor to perform the above-described method for switching between old and new data tables.

[0013] Fourthly, this application also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the above-described method for switching between old and new data tables through the computer program.

[0014] In this embodiment, the following steps are taken: The original data table in the business system is obtained, and a new data table is created based on the structure of the original data table; all program code in the business code of the business system that references the original data table is modified to reference the new data table; a target plugin with encryption / decryption annotations and mapping relationships is added to the business system, so that the business system uses the original data table and skips the encryption / decryption mechanism corresponding to the encryption / decryption annotations during operation. The encryption / decryption annotations are used to mark fields of private data that need to be encrypted / decrypted, and the mapping relationship is a mapping relationship between the new data table and the original data table; all data in the original data table is encrypted and synchronized to the new data table, and after synchronization, the mapping relationship in the target plugin is removed, so that the business system uses the new data table and operates... The above encryption / decryption mechanism achieves its goal by creating a new data table to replace the old one containing privacy data, maintaining a consistent structure between the old and new tables. It also replaces references to the old data table in the business code with the new one, and develops a target plugin for dynamic configuration. The new data table is used based on this configuration, allowing developers flexibility in debugging and switching. Data in both tables is synchronized, and the target plugin's mapping is removed after synchronization. This ensures encrypted storage of privacy data, minimizing the impact on business logic, ensuring business continuity and consistency, meeting privacy protection and compliance requirements, and improving the efficiency of data table migration. Ultimately, this solves the technical problem of low efficiency in manually migrating online business data tables, which hinders the normal operation of online businesses. Attached Figure Description

[0015] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0016] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0017] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.

[0018] Figure 1 This is a flowchart of an optional method for switching between old and new data tables according to an embodiment of this application;

[0019] Figure 2 This is a schematic diagram of an optional device for switching between old and new data tables according to an embodiment of this application;

[0020] Figure 3 This is a schematic diagram of an optional electronic device according to an embodiment of this application. Detailed Implementation

[0021] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0022] The following disclosure provides numerous different embodiments or examples for implementing various structures of this application. To simplify the disclosure, specific examples of components and arrangements are described below. These are merely examples and are not intended to limit the scope of this application. Furthermore, reference numerals and / or letters may be repeated in different examples. Such repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed.

[0023] According to a first aspect of the embodiments of this application, a method for switching between old and new data tables is provided, optionally, as follows: Figure 1 As shown, the above method includes:

[0024] S102, Obtain the original data table from the business system and create a new data table based on the structure of the original data table;

[0025] S104, Modify all program code in the business code of the business system that references the original data table to reference the new data table;

[0026] S106, Add a target plugin with encryption / decryption annotations and mapping relationships to the business system so that the business system can use the original data table and skip the encryption / decryption mechanism corresponding to the encryption / decryption annotations during operation. The encryption / decryption annotations are used to mark the fields of privacy data that need to be encrypted / decrypted, and the mapping relationship is the mapping relationship between the new data table and the original data table.

[0027] S108 encrypts and synchronizes all data from the original data table to the new data table. After synchronization, the mapping relationship in the target plugin is removed so that the business system can use the new data table and run the encryption / decryption mechanism during operation.

[0028] Optionally, in this embodiment, the target plugin is a MyBatis plugin. A MyBatis plugin is an extension mechanism of the MyBatis framework, allowing users to modify the core behavior of MyBatis through custom code. MyBatis plugins can intercept and modify SQL operations, parameter processing, and result processing executed by MyBatis. The methods that MyBatis plugins are allowed to intercept include: the SQL syntax constructor `StatementHandler`, the executor, the parameter handler `ParameterHandler`, and the result set handler `ResultSetHandler`. MyBatis plugins, combined with custom annotations and dynamic configuration in Java code, encrypt and intercept the `StatementHandler`, and decrypt and intercept the `ResultSetHandler`.

[0029] Optionally, in this embodiment, data encryption protection is implemented in the business system and migrated to a new data table. This ensures that sensitive data is stored encrypted in the database, while maintaining transparent access to the data table in the business code. Specifically, firstly, it is necessary to understand the structure and content of the existing data table in the business system, especially the fields containing private data. An initial data table is created in the business system with the same structure as the original data table. The length of all fields containing private data in the initial data table is modified to the target length to accommodate the encrypted data (usually the length of the encrypted data will increase), resulting in a new data table with an updated structure. This ensures that the new data table can store the encrypted data, avoiding data truncation or storage failure issues. In the business code of the business system, all code sections referencing the original data table are identified, and these code sections are modified to reference the new data table. Add a target plugin to the business system. This plugin dynamically handles the mapping relationships and encryption / decryption logic of data tables based on configuration. Define an annotation to mark privacy data fields that require encryption / decryption. Configure the mapping relationship between the new data table and the original data table. Configure a mechanism to skip encryption / decryption; when the mapping relationship exists, skip the encryption / decryption logic corresponding to the annotation. The business system can dynamically adjust the data access method at runtime based on the configuration, enabling seamless switching and verification of the correctness of the data encryption logic during migration. Encrypt the data in the original data table and then synchronize the encrypted data to the new data table. After synchronization, remove the mapping relationship configuration from the target plugin. During the business system's operation, since no mapping relationship configuration exists, the encryption / decryption mechanism is enabled, causing the business code to automatically perform encryption / decryption operations when processing data. Ultimately, the business system will fully rely on the new data table and automatically perform encryption and decryption operations when processing privacy data, ensuring data security during transmission and storage.

[0030] Optionally, in this embodiment, a new data table is created to replace the old data table containing privacy data. The structures of the old and new data tables are kept consistent. At the same time, the references to the original data table in the business code are changed to the new data table. A target plugin is developed for dynamic configuration, and the decision to use the new data table is based on the configuration, leaving space for developers to debug and switch flexibly. The data in the old and new data tables are updated synchronously. After the data synchronization is completed, the mapping relationship of the target plugin is removed to achieve encrypted storage of privacy data. This achieves the goal of minimizing the impact on business logic, ensuring business continuity and consistency, meeting privacy protection and compliance requirements, and improving the efficiency of data table migration. In this way, it solves the technical problem that the low efficiency of manually migrating data tables for online business affects the normal operation of online business.

[0031] As an optional example, creating a new data table based on the structure of the original data table includes:

[0032] Create an initial data table in the business system, where the initial data table has the same structure as the original data table;

[0033] Modify the length of all privacy data fields in the initial data table to the target length to obtain a new data table.

[0034] Optionally, in this embodiment, the specific process of creating a new data table based on the structure of the original data table includes: creating an initial data table in the business system, whose structure is the same as the original data table; modifying the field length of all privacy data in the initial data table to the target length to accommodate the encrypted data (usually the length of the encrypted data will increase), resulting in a new data table with an updated structure, ensuring that the new data table can store the encrypted data and avoiding data truncation or storage failure issues.

[0035] As an optional example, modifying all program code in the business code of the business system that references the original data table to reference the new data table includes:

[0036] Search and mark all program code in the business logic that references the original data table;

[0037] Modify all program code references to reference the new data table.

[0038] Optionally, to modify all program code in the business system that references the original data table to reference the new data table, in this embodiment, a static code analysis tool is used to scan the entire business code to find all references to the original data table. The global search function of a text editor is used to find all SQL queries, inserts, updates, and deletes involving the original data table. Comments are added to the discovered code referencing the original data table, marking the locations that need modification for clearer understanding in subsequent operations. A list is created to record all discovered code files referencing the original data table and their line numbers for systematic modification. The batch replace function of a text editor is used to change all references to the original data table to references to the new data table. In SQL queries, the original data table name is replaced with the new data table name, and field names are checked for adjustments.

[0039] As an optional example, the approach also includes adding a target plugin with encryption / decryption annotations and mapping relationships to the business system before:

[0040] Create the configuration file for the target plugin;

[0041] Create encryption / decryption annotations based on all privacy data fields in the original data table;

[0042] Create a mapping relationship based on the original data table and the new data table;

[0043] Add encryption / decryption annotations and mapping relationships to the configuration file.

[0044] Optionally, to achieve dynamic management of data encryption and decryption, a configuration file for the target plugin needs to be created, and encryption / decryption annotations and mapping relationships need to be set according to the structure of the original and new data tables. In this embodiment, the target plugin can dynamically process the mapping relationship and encryption / decryption logic of the data tables according to the configuration. It defines an annotation to mark the privacy data fields that need to be encrypted / decrypted, configures the mapping relationship between the new data table and the original data table, and configures a mechanism to skip encryption / decryption. When the mapping relationship exists, the encryption / decryption logic corresponding to the encryption / decryption annotation is skipped. The business system can dynamically adjust the data access method at runtime according to the configuration, enabling seamless switching and verification of the correctness of the data encryption logic during the migration process. For example, if the mapping relationship is maintained in the dynamic configuration, the plugin will automatically replace the new data table in the business logic with the original data table, and the encryption / decryption mechanism in the code will also be disabled, so the traffic will still go through the original data table. However, if there is no mapping relationship in the dynamic configuration, the traffic will go through the new data table according to the code settings, and the encryption / decryption mechanism will take effect according to the predetermined logic.

[0045] As an optional example, encrypting and synchronizing all data from the original data table to the new data table includes:

[0046] All private data in the original data table will be encrypted and synchronized to the new data table;

[0047] Synchronize all data in the original data table except for privacy data to the new data table.

[0048] Optionally, in this embodiment, the privacy data can be personal information such as mobile phone numbers and email addresses. During the process of encrypting and synchronizing all data from the original data table to the new data table, it is first necessary to identify all privacy data fields in the original data table that need to be encrypted, and extract all records containing privacy data from the original data table. The extracted privacy data is then encrypted using a predefined encryption algorithm, which can be symmetric or asymmetric encryption. The encrypted privacy data is written into the corresponding fields of the new data table to ensure data integrity and consistency. Next, fields in the original data table that do not need to be encrypted are identified. These fields may include public information, statistical data, or non-sensitive data. All fields and data that do not involve privacy are extracted from the original data table, and the extracted non-privacy data is directly written into the corresponding fields of the new data table, completing the data migration from the original data table.

[0049] As an optional example, removing mappings from the target plugin to enable the business system to use the new data table and run encryption / decryption mechanisms during runtime includes:

[0050] Based on the encryption and decryption mechanism, all private data generated during the operation of the business system will be encrypted and stored in the corresponding field of the new data table.

[0051] Optionally, in this embodiment, if a mapping relationship is maintained in the dynamic configuration during the operation of the business system, the plugin will automatically replace the new data table in the business logic with the original data table, and the encryption / decryption mechanism in the code will also be disabled, so the traffic will still go through the original data table. However, if there is no mapping relationship in the dynamic configuration, the traffic will go through the new data table according to the code settings, the encryption / decryption mechanism will take effect according to the predetermined logic, and all privacy data generated during operation will be encrypted and stored in the corresponding field of the new data table.

[0052] As an optional example, after removing the mappings from the target plugin, the method also includes:

[0053] If an anomaly is detected in the business system, a mapping relationship is added to the target plugin again so that the business system can use the original data table and skip the encryption / decryption mechanism during operation.

[0054] After the business system returns to normal within the target time, the incremental data in the original data table will be encrypted and synchronized to the new data table;

[0055] Remove the mapping relationship so that the business system can use the new data table and run the encryption / decryption mechanism during operation.

[0056] Optionally, in this embodiment, if an anomaly occurs in the business system during the migration of the old and new data tables, the mapping relationship between the new data table and the original data table can be added back to the target plugin. This ensures that the business system redirects data requests back to the original data table during runtime, instead of the new data table, thus guaranteeing that the business system uses the original data table during the anomaly. After the business system returns to normal, it is confirmed that the system can run stably without any anomalies. It is determined that new or updated data (incremental data) will be added to the original data table after the business system returns to normal. This incremental data is encrypted, and the encrypted incremental data is synchronized to the new data table. Finally, the target plugin's configuration file is updated, removing the previously added mapping relationship configuration, causing the business system to point to the new data table again. The updated configuration file is then applied to the target plugin, ensuring that the system switches back from the original data table to the new data table. This ensures that if the business system finds that there is no mapping relationship in the dynamic configuration, traffic will go to the new data table according to the code settings, and the encryption / decryption mechanism will take effect according to the predetermined logic.

[0057] Optionally, this method creates a new data table in the database and modifies the mapping relationship between the business code and the plugin to achieve encrypted storage and decryption of the data without large-scale changes to the existing business logic and code. This method can seamlessly migrate old and new data tables without affecting the normal operation of the online business system. It does not require dual-write plugins, and after the plugin is developed, the cost of migrating to the new table is low, requiring only simple configuration and a small amount of development. This greatly reduces the risk of system migration and business interruption due to code modification and data synchronization, and improves the maintainability and scalability of the system.

[0058] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0059] According to another aspect of the embodiments of this application, an apparatus for switching between old and new data tables is also provided, such as... Figure 2 As shown, it includes:

[0060] The acquisition module 202 is used to acquire the original data table in the business system and create a new data table based on the structure of the original data table;

[0061] Modify module 204 to change all program code in the business code of the business system that references the original data table to reference the new data table;

[0062] The first addition module 206 is used to add target plugins with encryption / decryption annotations and mapping relationships to the business system, so that the business system can use the original data table and skip the encryption / decryption mechanism corresponding to the encryption / decryption annotation during operation. The encryption / decryption annotation is used to mark the fields of privacy data that need to be encrypted / decrypted, and the mapping relationship is the mapping relationship between the new data table and the original data table.

[0063] The first synchronization module 208 is used to encrypt and synchronize all data from the original data table to the new data table, and after the synchronization is completed, remove the mapping relationship in the target plugin so that the business system can use the new data table and run the encryption and decryption mechanism during operation.

[0064] Optionally, in this embodiment, the target plugin is a MyBatis plugin. A MyBatis plugin is an extension mechanism of the MyBatis framework, allowing users to modify the core behavior of MyBatis through custom code. MyBatis plugins can intercept and modify SQL operations, parameter processing, and result processing executed by MyBatis. The methods that MyBatis plugins are allowed to intercept include: the SQL syntax constructor `StatementHandler`, the executor, the parameter handler `ParameterHandler`, and the result set handler `ResultSetHandler`. MyBatis plugins, combined with custom annotations and dynamic configuration in Java code, encrypt and intercept the `StatementHandler`, and decrypt and intercept the `ResultSetHandler`.

[0065] Optionally, in this embodiment, data encryption protection is implemented in the business system and migrated to a new data table. This ensures that sensitive data is stored encrypted in the database, while maintaining transparent access to the data table in the business code. Specifically, firstly, it is necessary to understand the structure and content of the existing data table in the business system, especially the fields containing private data. An initial data table is created in the business system with the same structure as the original data table. The length of all fields containing private data in the initial data table is modified to the target length to accommodate the encrypted data (usually the length of the encrypted data will increase), resulting in a new data table with an updated structure. This ensures that the new data table can store the encrypted data, avoiding data truncation or storage failure issues. In the business code of the business system, all code sections referencing the original data table are identified, and these code sections are modified to reference the new data table. Add a target plugin to the business system. This plugin dynamically handles the mapping relationships and encryption / decryption logic of data tables based on configuration. Define an annotation to mark privacy data fields that require encryption / decryption. Configure the mapping relationship between the new data table and the original data table. Configure a mechanism to skip encryption / decryption; when the mapping relationship exists, skip the encryption / decryption logic corresponding to the annotation. The business system can dynamically adjust the data access method at runtime based on the configuration, enabling seamless switching and verification of the correctness of the data encryption logic during migration. Encrypt the data in the original data table and then synchronize the encrypted data to the new data table. After synchronization, remove the mapping relationship configuration from the target plugin. During the business system's operation, since no mapping relationship configuration exists, the encryption / decryption mechanism is enabled, causing the business code to automatically perform encryption / decryption operations when processing data. Ultimately, the business system will fully rely on the new data table and automatically perform encryption and decryption operations when processing privacy data, ensuring data security during transmission and storage.

[0066] Optionally, in this embodiment, a new data table is created to replace the old data table containing privacy data. The structures of the old and new data tables are kept consistent. At the same time, the references to the original data table in the business code are changed to the new data table. A target plugin is developed for dynamic configuration, and the decision to use the new data table is based on the configuration, leaving space for developers to debug and switch flexibly. The data in the old and new data tables are updated synchronously. After the data synchronization is completed, the mapping relationship of the target plugin is removed to achieve encrypted storage of privacy data. This achieves the goal of minimizing the impact on business logic, ensuring business continuity and consistency, meeting privacy protection and compliance requirements, and improving the efficiency of data table migration. In this way, it solves the technical problem that the low efficiency of manually migrating data tables for online business affects the normal operation of online business.

[0067] As an optional example, the modules to be acquired include:

[0068] The creation unit is used to create an initial data table in the business system, wherein the initial data table has the same structure as the original data table;

[0069] The first modification unit is used to modify the field length of all privacy data in the initial data table to the target length, thereby obtaining a new data table.

[0070] Optionally, in this embodiment, the specific process of creating a new data table based on the structure of the original data table includes: creating an initial data table in the business system, whose structure is the same as the original data table; modifying the field length of all privacy data in the initial data table to the target length to accommodate the encrypted data (usually the length of the encrypted data will increase), resulting in a new data table with an updated structure, ensuring that the new data table can store the encrypted data and avoiding data truncation or storage failure issues.

[0071] As an optional example, the modified module includes:

[0072] The tagging unit is used to search for and tag all program code in the business logic that references the original data table;

[0073] The second modification unit is used to change the reference relationships of all program code to reference the new data table.

[0074] Optionally, to modify all program code in the business system that references the original data table to reference the new data table, in this embodiment, a static code analysis tool is used to scan the entire business code to find all references to the original data table. The global search function of a text editor is used to find all SQL queries, inserts, updates, and deletes involving the original data table. Comments are added to the discovered code referencing the original data table, marking the locations that need modification for clearer understanding in subsequent operations. A list is created to record all discovered code files referencing the original data table and their line numbers for systematic modification. The batch replace function of a text editor is used to change all references to the original data table to references to the new data table. In SQL queries, the original data table name is replaced with the new data table name, and field names are checked for adjustments.

[0075] As an optional example, the above-described apparatus further includes:

[0076] The first creation module is used to create the configuration file for the target plugin before adding the target plugin with encryption / decryption annotations and mapping relationships to the business system;

[0077] The second creation module is used to create encryption / decryption annotations based on the fields of all privacy data in the original data table;

[0078] The third creation module is used to create mapping relationships based on the original data table and the new data table;

[0079] The second module is used to add encryption / decryption annotations and mapping relationships to the configuration file.

[0080] Optionally, to achieve dynamic management of data encryption and decryption, a configuration file for the target plugin needs to be created, and encryption / decryption annotations and mapping relationships need to be set according to the structure of the original and new data tables. In this embodiment, the target plugin can dynamically process the mapping relationship and encryption / decryption logic of the data tables according to the configuration. It defines an annotation to mark the privacy data fields that need to be encrypted / decrypted, configures the mapping relationship between the new data table and the original data table, and configures a mechanism to skip encryption / decryption. When the mapping relationship exists, the encryption / decryption logic corresponding to the encryption / decryption annotation is skipped. The business system can dynamically adjust the data access method at runtime according to the configuration, enabling seamless switching and verification of the correctness of the data encryption logic during the migration process. For example, if the mapping relationship is maintained in the dynamic configuration, the plugin will automatically replace the new data table in the business logic with the original data table, and the encryption / decryption mechanism in the code will also be disabled, so the traffic will still go through the original data table. However, if there is no mapping relationship in the dynamic configuration, the traffic will go through the new data table according to the code settings, and the encryption / decryption mechanism will take effect according to the predetermined logic.

[0081] As an optional example, the synchronization module includes:

[0082] The first synchronization unit is used to encrypt and synchronize all private data in the original data table to the new data table;

[0083] The second synchronization unit is used to synchronize all data in the original data table, except for privacy data, to the new data table.

[0084] Optionally, in this embodiment, the privacy data can be personal information such as mobile phone numbers and email addresses. During the process of encrypting and synchronizing all data from the original data table to the new data table, it is first necessary to identify all privacy data fields in the original data table that need to be encrypted, and extract all records containing privacy data from the original data table. The extracted privacy data is then encrypted using a predefined encryption algorithm, which can be symmetric or asymmetric encryption. The encrypted privacy data is written into the corresponding fields of the new data table to ensure data integrity and consistency. Next, fields in the original data table that do not need to be encrypted are identified. These fields may include public information, statistical data, or non-sensitive data. All fields and data that do not involve privacy are extracted from the original data table, and the extracted non-privacy data is directly written into the corresponding fields of the new data table, completing the data migration from the original data table.

[0085] As an optional example, the synchronization module includes:

[0086] The storage unit is used to encrypt all private data generated during the operation of the business system according to the encryption and decryption mechanism and store it in the corresponding field of the new data table.

[0087] Optionally, in this embodiment, if a mapping relationship is maintained in the dynamic configuration during the operation of the business system, the plugin will automatically replace the new data table in the business logic with the original data table, and the encryption / decryption mechanism in the code will also be disabled, so the traffic will still go through the original data table. However, if there is no mapping relationship in the dynamic configuration, the traffic will go through the new data table according to the code settings, the encryption / decryption mechanism will take effect according to the predetermined logic, and all privacy data generated during operation will be encrypted and stored in the corresponding field of the new data table.

[0088] As an optional example, the above-described apparatus further includes:

[0089] The third module is used to add a mapping relationship to the target plugin again after removing the mapping relationship in the target plugin, in the event that an anomaly is detected in the business system, so that the business system can use the original data table and skip the encryption and decryption mechanism during operation.

[0090] The second synchronization module is used to encrypt and synchronize the incremental data of the original data table to the new data table after the business system has returned to normal for the target period of time.

[0091] The removal module is used to remove mapping relationships so that the business system can use the new data table and run encryption / decryption mechanisms during operation.

[0092] Optionally, in this embodiment, if an anomaly occurs in the business system during the migration of the old and new data tables, the mapping relationship between the new data table and the original data table can be added back to the target plugin. This ensures that the business system redirects data requests back to the original data table during runtime, instead of the new data table, thus guaranteeing that the business system uses the original data table during the anomaly. After the business system returns to normal, it is confirmed that the system can run stably without any anomalies. It is determined that new or updated data (incremental data) will be added to the original data table after the business system returns to normal. This incremental data is encrypted, and the encrypted incremental data is synchronized to the new data table. Finally, the target plugin's configuration file is updated, removing the previously added mapping relationship configuration, causing the business system to point to the new data table again. The updated configuration file is then applied to the target plugin, ensuring that the system switches back from the original data table to the new data table. This ensures that if the business system finds that there is no mapping relationship in the dynamic configuration, traffic will go to the new data table according to the code settings, and the encryption / decryption mechanism will take effect according to the predetermined logic.

[0093] For other examples of this embodiment, please refer to the examples above, which will not be repeated here.

[0094] Figure 3 This is a schematic diagram of an optional electronic device according to an embodiment of this application, such as... Figure 3 As shown, it includes a processor 302, a communication interface 304, a memory 306, and a communication bus 308. The processor 302, communication interface 304, and memory 306 communicate with each other via the communication bus 308.

[0095] Memory 306 is used to store computer programs;

[0096] When processor 302 executes a computer program stored in memory 306, it performs the following steps:

[0097] Obtain the original data table from the business system and create a new data table based on the structure of the original data table;

[0098] Modify all program code in the business code of the business system that references the original data table to reference the new data table;

[0099] Add a target plugin with encryption / decryption annotations and mapping relationships to the business system so that the business system can use the original data table and skip the encryption / decryption mechanism corresponding to the encryption / decryption annotations during operation. The encryption / decryption annotations are used to mark the fields of private data that need to be encrypted / decrypted, and the mapping relationship is the mapping relationship between the new data table and the original data table.

[0100] All data from the original data table is encrypted and synchronized to the new data table. After synchronization, the mapping relationship in the target plugin is removed so that the business system can use the new data table and run the encryption / decryption mechanism during operation.

[0101] Optionally, in this embodiment, the communication bus can be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 The symbol is represented by a single thick line, but this does not indicate that there is only one bus or one type of bus. The communication interface is used for communication between the aforementioned electronic devices and other devices.

[0102] The memory may include RAM, or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0103] As an example, the memory 306 described above may include, but is not limited to, the acquisition module 202, modification module 204, first addition module 206, and first synchronization module 208 from the device for switching between old and new data tables. Furthermore, it may include, but is not limited to, other module units from the device for switching between old and new data tables, which will not be elaborated upon in this example.

[0104] The processors mentioned above can be general-purpose processors, including but not limited to: CPU (Central Processing Unit), NP (Network Processor), etc.; they can also be DSP (Digital Signal Processor), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0105] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments, and will not be repeated here.

[0106] Those skilled in the art will understand that Figure 3 The structure shown is for illustrative purposes only. The device that implements the above method of switching between old and new data tables can be a terminal device, such as a smartphone (e.g., Android phone, iOS phone), tablet computer, PDA, mobile Internet Devices (MID), PAD, etc. Figure 3 This does not limit the structure of the aforementioned electronic devices. For example, the electronic device may also include components that are more... Figure 3 The more or fewer components shown (such as network interfaces, display devices, etc.), or having the same Figure 3 The different configurations shown.

[0107] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, ROM, RAM, disk or optical disk, etc.

[0108] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer program, which, when executed by a processor, performs the steps in the method for switching between old and new data tables described above.

[0109] Optionally, in this embodiment, those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0110] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0111] If the integrated units in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in the aforementioned 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 several instructions to cause one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.

[0112] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0113] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units 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, indirect coupling or communication connection between units or modules, and may be electrical or other forms.

[0114] The units described 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.

[0115] 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.

[0116] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A method for switching between old and new data tables, characterized in that, include: Obtain the original data table from the business system, and create a new data table based on the structure of the original data table; Modify all program code in the business code of the business system that references the original data table to reference the new data table; Add a target plugin with encryption / decryption annotations and mapping relationships to the business system so that the business system can use the original data table and skip the encryption / decryption mechanism corresponding to the encryption / decryption annotations during operation. The encryption / decryption annotations are used to mark the fields of privacy data that need to be encrypted / decrypted, and the mapping relationship is the mapping relationship between the new data table and the original data table. All data in the original data table is encrypted and synchronized to the new data table. After synchronization is complete, the mapping relationship in the target plugin is removed so that the business system can use the new data table and run the encryption / decryption mechanism during operation.

2. The method according to claim 1, characterized in that, The step of creating a new data table based on the structure of the original data table includes: An initial data table is created in the business system, wherein the initial data table has the same structure as the original data table; Modify the field length of all privacy data in the initial data table to the target length to obtain the new data table.

3. The method according to claim 1, characterized in that, The step of modifying all program code in the business code of the business system that references the original data table to reference the new data table includes: Search and mark all program code in the business logic that references the original data table; Modify all references in the program code to reference the new data table.

4. The method according to claim 1, characterized in that, Before adding the target plugin with encryption / decryption annotations and mapping relationships to the business system, the method further includes: Create the configuration file for the target plugin; The encryption / decryption annotation is created based on all the fields of the privacy data in the original data table; The mapping relationship is created based on the original data table and the new data table; Add the encryption / decryption annotations and the mapping relationship to the configuration file.

5. The method according to claim 1, characterized in that, The step of encrypting and synchronizing all data from the original data table to the new data table includes: All privacy data in the original data table is encrypted and synchronized to the new data table; Synchronize all data in the original data table except for privacy data to the new data table.

6. The method according to claim 1, characterized in that, The step of removing the mapping relationship from the target plugin so that the business system can use the new data table and run the encryption / decryption mechanism during operation includes: According to the encryption and decryption mechanism, all privacy data generated during the operation of the business system will be encrypted and stored in the corresponding field of the new data table.

7. The method according to claim 1, characterized in that, After removing the mapping relationship from the target plugin, the method further includes: If an anomaly is detected in the business system, the mapping relationship is added to the target plugin again so that the business system can use the original data table and skip the encryption / decryption mechanism during operation. After the target time period for the business system to return to normal, the incremental data of the original data table will be encrypted and synchronized to the new data table; Remove the mapping relationship so that the business system can use the new data table and run the encryption / decryption mechanism during operation.

8. A device for switching between old and new data tables, characterized in that, include: The acquisition module is used to acquire the original data table in the business system and create a new data table based on the structure of the original data table; The modification module is used to modify all program code in the business code of the business system that references the original data table to reference the new data table; The first addition module is used to add a target plugin with encryption / decryption annotations and mapping relationships to the business system, so that the business system can use the original data table and skip the encryption / decryption mechanism corresponding to the encryption / decryption annotations during operation. The encryption / decryption annotations are used to mark the fields of privacy data that need to be encrypted / decrypted, and the mapping relationship is the mapping relationship between the new data table and the original data table. The first synchronization module is used to encrypt and synchronize all data in the original data table to the new data table, and after the synchronization is completed, remove the mapping relationship in the target plugin so that the business system can use the new data table and run the encryption and decryption mechanism during operation.

9. A computer-readable storage medium storing a computer program, characterized in that, The computer program is executed by the processor to perform the method described in any one of claims 1 to 7.

10. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to execute the method described in any one of claims 1 to 7 through the computer program.

Citation Information

Patent Citations

  • Data migration method and device of heterogeneous system, computer equipment and storage medium

    CN112434004A

  • Real-time synchronization method based on provincial-level actual population data

    CN115658649A