A system upgrading method, device and equipment based on GO language and a medium
By using an automated system upgrade method based on the Go language, the problems of low efficiency in system database upgrades and human error were solved, achieving efficient and accurate database initialization and upgrades.
Patent Information
- Application Number
- CN202210672397.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-15
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2042-06-15
AI Technical Summary
In existing technologies, system database upgrades are inefficient and prone to human error, leading to increased development time and costs.
An automated system upgrade method based on the Go language is adopted. It checks whether the database exists in the system to be upgraded. If it does not exist, it initializes the database. If it exists, it compares the version and upgrades based on the changed data table structure. The xorm framework of the Go language is used to synchronize the data table structure to achieve automated upgrade.
This improved the efficiency of system upgrades, reduced error rates and development time costs, and ensured the accuracy and efficiency of database upgrades.
Smart Images

Figure CN115145892B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present specification relates to the technical field of computer, and particularly relates to a system upgrading method and device based on GO language, equipment and medium. BACKGROUND
[0002] With the popularity of the Internet and the development of mobile Internet, the user data to be processed has experienced explosive growth, and the development of various systems has paid more and more attention to running efficiency. In order to meet the new needs of customers and improve the system running efficiency, it is usually necessary to upgrade the database of the system. Therefore, the initialization and upgrading of the system have always been the focus of the developers.
[0003] In the prior art, the creation and upgrading of the database are usually performed by the manual upgrading method of the developers. However, the efficiency of this method is too low, and the operation based on human operation is prone to operation errors. In addition, the process of manual upgrading by the developers also consumes the development time of the developers, thereby causing the increase of the system upgrading cost.
[0004] Therefore, there is a need for an efficient method capable of automatically creating and upgrading the database according to the system. SUMMARY
[0005] One or more embodiments of the present specification provide a system upgrading method and device based on GO language, equipment and medium, which are used to solve the technical problem of how to provide a method capable of automatically creating and upgrading the database according to the system.
[0006] One or more embodiments of the present specification adopt the following technical solutions:
[0007] One or more embodiments of the present specification provide a system upgrading method based on GO language, and the method comprises the following steps:
[0008] Starting the system to be upgraded based on a preset program, and detecting whether there is a database to be upgraded in the system to be upgraded;
[0009] If not, initializing the database of the system to be upgraded based on GO language;
[0010] If yes, obtaining a first system version in the database to be upgraded and a second system version of the system to be upgraded corresponding to the database to be upgraded, and comparing the first system version with the second system version;
[0011] If it is determined that the first system version is not the same as the second system version, and the second system version is greater than the first system version, a change data table structure body in the corresponding system is determined based on the GO language to upgrade the database to be upgraded based on the change data table structure body.
[0012] Optionally, in one or more embodiments of the present specification, the detection of whether the system to be upgraded has a database to be upgraded specifically comprises:
[0013] Determining the database name of the database to be upgraded;
[0014] Querying the database file corresponding to the database name under the project directory of the system to be upgraded;
[0015] If there is a database file corresponding to the database name, the system to be upgraded has the database to be upgraded;
[0016] If there is no database file corresponding to the database name, the system to be upgraded does not have the database to be upgraded.
[0017] Optionally, in one or more embodiments of the present specification, the database initialization of the system to be upgraded based on the GO language specifically comprises:
[0018] Obtaining a pre-set data table structure body in the xorm framework of the GO language;
[0019] Synchronizing the data table structure body to the system to be upgraded to realize the database initialization of the system to be upgraded.
[0020] Optionally, in one or more embodiments of the present specification, before obtaining the pre-set data table structure body in the xorm framework of the GO language, the method further comprises:
[0021] Determining the database name corresponding to the second system version of the system to be upgraded;
[0022] Obtaining a custom target field corresponding to the database name based on a pre-set SQL statement;
[0023] Obtaining a pre-set data table structure body template, filling the database name and the custom target field into the corresponding positions in the data table structure body template, and obtaining the pre-set data table structure body.
[0024] Optionally, in one or more embodiments of the present specification, after synchronizing the data table structure body to the system to be upgraded to realize the database initialization of the system to be upgraded, the method further comprises:
[0025] Obtaining the configuration file after the database is initialized, executing the SQL statements preset by each initial data in the configuration file to create the database corresponding to the database to be upgraded.
[0026] Optionally, in one or more embodiments of the present specification, the GO language-based determination of the change data table structure in the corresponding system is to upgrade the database to be upgraded based on the change data table structure, specifically comprising:
[0027] Obtaining the data table structure corresponding to the second system version;
[0028] Determining whether the data table structure corresponding to the second system version is the same as the data table structure corresponding to the first system version;
[0029] If not, based on the sync in the xorm framework of the GO language, the change data table structure corresponding to the second system version is synchronized in the data table structure of the database to be upgraded.
[0030] Optionally, in one or more embodiments of the present specification, after the change data table structure corresponding to the second system version is synchronized in the data table structure of the database to be upgraded based on the sync in the xorm framework of the GO language, the method further comprises:
[0031] Obtaining the newly added field of the data table structure corresponding to the second system version relative to the data table structure corresponding to the first system version, and setting the newly added field to a default value.
[0032] One or more embodiments of the present specification provide a GO language-based system upgrading device, the device comprising:
[0033] A detection unit for starting a system to be upgraded based on a preset program, detecting whether there is a database to be upgraded in the system to be upgraded;
[0034] An initialization unit for initializing the database of the system to be upgraded based on the GO language if there is not;
[0035] A comparison unit for obtaining the first system version in the database to be upgraded and the second system version of the system to be upgraded corresponding to the database to be upgraded if there is, and comparing the first system version with the second system version;
[0036] The upgrading unit is configured to, if it is determined that the first system version is not the same as the second system version and the second system version is greater than the first system version, determine a change data table structure in the corresponding system based on the GO language, and upgrade the database to be upgraded based on the change data table structure.
[0037] One or more embodiments of the present specification provide a GO language-based system upgrading device, which comprises:
[0038] at least one processor; and
[0039] a memory in communication connection with the at least one processor; wherein
[0040] the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to:
[0041] start a system to be upgraded based on a preset program, and detect whether there is a database to be upgraded in the system to be upgraded;
[0042] if not, initialize a database of the system to be upgraded based on the GO language;
[0043] if yes, acquire a first system version in the database to be upgraded and a second system version of a system to be upgraded corresponding to the database to be upgraded, and compare the first system version with the second system version;
[0044] if it is determined that the first system version is not the same as the second system version and the second system version is greater than the first system version, determine a change data table structure in the corresponding system based on the GO language, and upgrade the database to be upgraded based on the change data table structure.
[0045] One or more embodiments of the present specification provide a non-volatile computer storage medium, which stores computer executable instructions configured to:
[0046] start a system to be upgraded based on a preset program, and detect whether there is a database to be upgraded in the system to be upgraded;
[0047] if not, initialize a database of the system to be upgraded based on the GO language;
[0048] if yes, acquire a first system version in the database to be upgraded and a second system version of a system to be upgraded corresponding to the database to be upgraded, and compare the first system version with the second system version;
[0049] If it is determined that the first system version and the second system version are not the same, and the second system version is greater than the first system version, a change data table structure body in the corresponding system is determined based on the GO language to upgrade the database to be upgraded based on the change data table structure body.
[0050] The above at least one technical solution adopted by the embodiments of the present specification can achieve the following beneficial effects:
[0051] When it is detected that there is no database to be upgraded in the system to be upgraded, database initialization of the system to be upgraded through the GO language avoids possible erroneous operations in the process of creating the database in a manual manner, and saves the development time of the developer. If there is a database to be upgraded, the first system version in the database to be upgraded and the second system version of the system to be upgraded corresponding to the database to be upgraded are compared, and the database to be upgraded is upgraded according to the change data table structure body in the corresponding system determined based on the GO language, which realizes automatic upgrading of the system, improves the efficiency of the system, and reduces the error rate in the upgrading process. BRIEF DESCRIPTION OF DRAWINGS
[0052] In order to more clearly illustrate the technical solutions in the embodiments of the present specification or the prior art, the drawings needed to be used in the embodiments or prior art description will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments described in the present specification, and other drawings can be obtained by those skilled in the art without creative labor. In the drawings:
[0053] Figure 1 A method flowchart of a system upgrading method based on the GO language provided by the embodiments of the present specification;
[0054] Figure 2 An execution flowchart of a system upgrading method based on the GO language in an application scenario provided by the embodiments of the present specification;
[0055] Figure 3 An internal structure schematic diagram of a system upgrading apparatus based on the GO language provided by the embodiments of the present specification;
[0056] Figure 4 An internal structure schematic diagram of a system upgrading apparatus based on the GO language provided by the embodiments of the present specification;
[0057] Figure 5 An internal structure schematic diagram of a non-volatile storage medium provided by the embodiments of the present specification. DETAILED DESCRIPTION
[0058] Embodiments of the present specification provide a system upgrade method and device based on GO language, equipment and medium.
[0059] In recent years, with the rise of the Internet industry, the development of various system software has also paid more and more attention to running efficiency. GO language is widely used in the development of various systems by various companies due to its high efficiency. System initialization and upgrade has always been a problem for developers. The traditional way is to manually create and upgrade the database, which is inefficient and prone to human error. To solve the above technical problems, embodiments of the present specification provide a system upgrade method and device based on GO language, equipment and medium.
[0060] In order to enable personnel in the art to better understand the technical solutions in the present specification, the technical solutions in the embodiments of the present specification will be described clearly and completely in conjunction with the drawings in the embodiments of the present specification. Obviously, the described embodiments are only part of the embodiments of the present specification, not all embodiments. Based on the embodiments of the present specification, all other embodiments obtained by those of ordinary skill in the art without creative labor should fall within the scope of protection of the present specification.
[0061] As shown in Figure 1 , a method flow diagram of a system upgrade method based on GO language is provided in one or more embodiments of the present specification. As shown in Figure 1 , the method comprises the following steps:
[0062] S101: Start the system to be upgraded based on the preset program, and detect whether the system to be upgraded has a database to be upgraded.
[0063] With the rapid development of the Internet, the development of system software has higher and higher requirements for running efficiency. In order to improve the user experience and upgrade the database of the system in time, and improve the running efficiency of the system. In the embodiment of the present specification, the system to be upgraded is first started based on the preset program. Whether there is a database to be upgraded in the system to be upgraded is detected, so as to carry out subsequent initialization and upgrading of the database to be upgraded and the like. In one or more embodiments of the present specification, detecting whether the system to be upgraded has a database to be upgraded specifically includes the following steps: first, the database name of the database to be upgraded in the system to be upgraded is determined, and then it is queried whether the database file corresponding to the database name exists in the project directory of the system to be upgraded. If the database file corresponding to the database name exists in the project directory, then the system to be upgraded has a database to be upgraded. If the database file corresponding to the database name does not exist in the project directory, then the system to be upgraded does not have a database to be upgraded. By detecting whether the system to be upgraded has a database to be upgraded, the foundation for subsequent creation or upgrading of the database to be upgraded is laid, and the efficiency of system upgrading is improved.
[0064] S102: If not, initializing the database of the system to be upgraded based on the GO language.
[0065] If the system to be upgraded is detected based on the above step S101, and it is determined that the system to be upgraded does not have a database to be upgraded, in order to avoid the problem of high error rate caused by manual creation of the database and the problem of waste of time cost of the developer. In the embodiment of the present specification, the database of the system to be upgraded is initialized through the GO language. It should be noted that the GO language is a programming language that can reduce the complexity of the code without losing the performance of the application.
[0066] Specifically, in one or more embodiments of the present specification, the database of the system to be upgraded is initialized based on the GO language, specifically including the following steps: first, the data table structure body preset in the xorm framework of the GO language is obtained. Then synchronize the data table structure body to the system to be upgraded, so as to realize the database initialization operation of the system to be upgraded, realize the automatic database initialization of the system to be upgraded, and avoid the unstable factors caused by the manual creation process.
[0067] In order to initialize the to-be-upgraded database based on the data table structure body. In one or more embodiments of the present specification, before obtaining the data table structure body preset in the xorm framework of the GO language, the method further comprises the following process: determining the database name corresponding to the system version of the to-be-upgraded system; then obtaining the custom target field corresponding to the database name according to the pre-set SQL statement. Then obtain the preset data table structure template, fill the database name and the custom target field into the corresponding position in the data table structure template, so as to obtain the preset data table structure body. Through the preset of the data table structure body, the system can directly initialize the database of the system based on the data table structure body when the to-be-upgraded database does not exist, thereby improving the efficiency of system upgrading and saving the setting creation time.
[0068] In order to realize the rapid creation of the database, in one or more embodiments of the present specification, after synchronizing the data table structure body with the to-be-upgraded system and initializing the database of the to-be-upgraded system, the method further comprises the following process: obtaining the configuration file after the database initialization, and then executing the SQL statement preset by each initial data in the configuration file, thereby creating the database corresponding to the to-be-upgraded database.
[0069] S103: If it exists, obtain the first system version in the to-be-upgraded database and the second system version of the to-be-upgraded system corresponding to the to-be-upgraded database, and compare the first system version with the second system version.
[0070] If it is determined based on the above step S101 that the to-be-upgraded database exists in the to-be-upgraded system, in order to avoid the problem that the system running efficiency is limited due to the inconsistency between the database version and the system version in the to-be-upgraded system. In the embodiment of the present specification, the first system version in the to-be-upgraded database and the second system version of the to-be-upgraded system corresponding to the to-be-upgraded database are obtained, so as to compare the version numbers of the first system version and the second system version, and determine whether they are the same, thereby avoiding the problem that the system running speed is slow due to the database version being lower than the system version.
[0071] S104: If it is determined that the first system version and the second system version are not the same, and the second system version is greater than the first system version, then determine the changed data table structure body in the corresponding system based on the GO language, and upgrade the to-be-upgraded database based on the changed data table structure body.
[0072] If it is determined based on the comparison in step S103 that the first system version and the second system version are different in version, and the second system version of the system is greater than the first system version of the database, then the changed data table structure in the corresponding system needs to be determined based on the GO language, and then the upgraded database is upgraded based on the determined changed data table structure. In one or more embodiments of the present specification, the changed data table structure in the corresponding system is determined based on the GO language to upgrade the database to be upgraded based on the changed data table structure, specifically including the following steps: obtaining the data table structure corresponding to the second system version; determining whether the data table structure corresponding to the second system version is the same as the data table structure corresponding to the first system version; if not, based on the sync function in the xorm framework of the GO language, the changed data table structure corresponding to the second system version is synchronized to the data table structure of the database to be upgraded.
[0073] Further, in one or more embodiments of the present specification, after the changed data table structure corresponding to the second system version is synchronized to the data table structure of the database to be upgraded based on the sync in the xorm framework of the GO language, the method further includes: obtaining the newly added field of the data table structure corresponding to the second system version relative to the data table structure corresponding to the first system version, and setting the newly added field to a default value.
[0074] As shown in Figure 2 , the present specification provides a system upgrade execution flowchart based on the GO language in an application scenario. As can be seen from Figure 2 , after the system is started, it is first checked whether the system has a database. If there is no database, then the creation of the database and the writing of the initial data based on the GO language are performed to start the system. If there is a database, then the system version stored in the database is checked to see if the version in the configuration file is greater than the version in the database. If so, the database upgrade file is executed to implement the database upgrade operation. Based on this way, the creation and upgrade operation of the database by human is avoided, the efficiency is improved, and the error rate is reduced.
[0075] As shown in Figure 3 , the present specification provides an internal structure diagram of a system upgrade device based on the GO language in one or more embodiments. As can be seen from Figure 3 , a system upgrade device based on the GO language includes:
[0076] The detection unit 301 is configured to start the system to be upgraded based on a preset program, and detect whether the system to be upgraded has a database to be upgraded.
[0077] The initialization unit 302 is configured to initialize the database of the system to be upgraded based on the GO language if there is no database to be upgraded.
[0078] The comparison unit 303 is configured to acquire a first system version in the database to be upgraded and a second system version of a system to be upgraded corresponding to the database to be upgraded, and compare the first system version with the second system version.
[0079] The upgrading unit 304 is configured to determine, if the first system version is different from the second system version and the second system version is greater than the first system version, a change table structure body in the corresponding system based on the GO language, and upgrade the database to be upgraded based on the change table structure body.
[0080] Further, the detection unit specifically comprises:
[0081] The first determination unit is configured to determine a database name of the database to be upgraded.
[0082] The query unit is configured to query a database file corresponding to the database name in a project directory of the system to be upgraded.
[0083] The first discrimination unit is configured to determine, if the database file corresponding to the database name exists, that the database to be upgraded exists in the system to be upgraded.
[0084] The second discrimination unit is configured to determine, if the database file corresponding to the database name does not exist, that the database to be upgraded does not exist in the system to be upgraded.
[0085] Further, the initialization unit specifically comprises:
[0086] The first acquisition unit is configured to acquire a data table structure body preset in an xorm framework of the GO language.
[0087] The first synchronization unit is configured to synchronize the data table structure body to the system to be upgraded, so as to initialize the database of the system to be upgraded.
[0088] Further, the apparatus further comprises:
[0089] The second determination unit is configured to determine a database name corresponding to the second system version of the system to be upgraded.
[0090] The second acquisition unit is configured to acquire a custom target field corresponding to the database name based on a preset SQL statement.
[0091] The third acquisition unit is configured to acquire a preset data table structure body template, fill the database name and the custom target field into corresponding positions in the data table structure body template, and obtain the preset data table structure body.
[0092] Further, the apparatus further comprises a fourth acquisition unit configured to acquire a configuration file after initialization of the database, and execute a preset SQL statement of each initial data in the configuration file to create a database corresponding to the database to be upgraded.
[0093] Further, the upgrading apparatus specifically comprises:
[0094] a fifth acquisition unit configured to acquire a data table structure corresponding to the second system version;
[0095] a determination unit configured to determine whether the data table structure corresponding to the second system version is same as the data table structure corresponding to the first system version;
[0096] a second synchronization unit configured to, if not, synchronize the changed data table structure corresponding to the second system version in the xorm framework of the GO language to the data table structure of the database to be upgraded.
[0097] Further, in one or more embodiments of the present specification, the apparatus further comprises:
[0098] a setting unit configured to acquire an added field of the data table structure corresponding to the second system version relative to the data table structure corresponding to the first system version, and set the added field as a default value.
[0099] As shown in Figure 4 , one or more embodiments of the present specification provide an internal structure diagram of a system upgrading device based on GO language. As can be seen from Figure 4 , the device comprises:
[0100] at least one processor 401; and
[0101] a memory 402 in communication connection with the at least one processor 401; wherein
[0102] the memory 402 stores instructions executable by the at least one processor 401, and the instructions are executed by the at least one processor 401 to enable the at least one processor 401 to:
[0103] start a system to be upgraded based on a preset program, and detect whether the system to be upgraded exists a database to be upgraded;
[0104] if not, initialize a database of the system to be upgraded based on GO language;
[0105] If the to-be-upgraded database exists, a first system version in the to-be-upgraded database and a second system version of a to-be-upgraded system corresponding to the to-be-upgraded database are acquired, and the first system version and the second system version are compared.
[0106] If it is determined that the first system version and the second system version are different, and the second system version is greater than the first system version, a change data table structure in the corresponding system is determined based on the GO language, and the to-be-upgraded database is upgraded based on the change data table structure.
[0107] As shown in Figure 5 , one or more embodiments of the present specification provide an internal structure diagram of a non-volatile storage medium. It can be known that a non-volatile storage medium stores computer executable instructions 501, and the computer executable instructions 501 include: Figure 5
[0108] The to-be-upgraded system is started based on a preset program, and whether the to-be-upgraded system has a to-be-upgraded database is detected.
[0109] If the to-be-upgraded database does not exist, the to-be-upgraded system is initialized based on the GO language.
[0110] If the to-be-upgraded database exists, a first system version in the to-be-upgraded database and a second system version of a to-be-upgraded system corresponding to the to-be-upgraded database are acquired, and the first system version and the second system version are compared.
[0111] If it is determined that the first system version and the second system version are different, and the second system version is greater than the first system version, a change data table structure in the corresponding system is determined based on the GO language, and the to-be-upgraded database is upgraded based on the change data table structure.
[0112] Each of the embodiments in the present specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other. Each embodiment mainly describes the difference from other embodiments. Especially, since the device, the equipment, and the non-volatile computer storage medium embodiment are basically similar to the method embodiment, the description is relatively simple, and the related parts can be referred to the part of the method embodiment.
[0113] The above-described embodiments of the application have several aspects, no single one of which is solely responsible for the application's desirable attributes. Without limiting the scope of this application, other aspects of the application will become apparent from consideration of the drawings and following detailed description, it being understood that such changes in the state of the art can be made without departing from the spirit and scope of the application. As will be realized, the application is capable of modifications in various obvious aspects, all without departing from the application and the
[0114] The foregoing is considered as illustrative only of the principles of the application. Further, since numerous modifications and changes will readily occur to those skilled in the art, it is not desired to limit the application to the exact construction and practice described. Accordingly, all such variations are intended to be included within the scope of the present application as defined in the following claims, along with full authority to claim such combinations of the subject matter described herein as fully as may be legally permitted.
Claims
1. A system upgrade method based on the Go language, characterized in that, The method includes: The system to be upgraded is started based on a preset program, and the system is checked to see if there is a database to be upgraded in the system. If it does not exist, the database of the system to be upgraded will be initialized using the Go language; If they exist, obtain the first system version in the database to be upgraded and the second system version of the system to be upgraded corresponding to the database to be upgraded, and compare the first system version with the second system version. If it is determined that the first system version and the second system version are different, and the second system version is greater than the first system version, then the corresponding changed data table structure in the system is determined based on the Go language, and the database to be upgraded is upgraded based on the changed data table structure. The database initialization of the system to be upgraded is performed using the Go programming language, specifically including: Obtain the pre-defined data table structure in the xorm framework of the Go language; Synchronize the data table structure with the system to be upgraded to initialize the database of the system to be upgraded. Before obtaining the pre-defined data table structure in the Go language's XORM framework, the method further includes: Determine the database name corresponding to the second system version of the system to be upgraded; Retrieve the custom target field corresponding to the database name based on a preset SQL statement; Obtain a pre-set data table structure template, fill the database name and the custom target field into the corresponding positions in the data table structure template, and obtain the pre-set data table structure; Based on the Go language, the corresponding changed number table structure in the system is determined, and the database to be upgraded is upgraded based on the changed number table structure, specifically including: Obtain the data table structure corresponding to the second system version; Determine whether the data table structure corresponding to the second system version is the same as the data table structure corresponding to the first system version; If not, then based on the sync function in the xorm framework of the Go language, the changed data table structure corresponding to the second system version will be synchronized to the data table structure of the database to be upgraded. Based on the `sync` function in the XORM framework of the Go language, after synchronizing the changed data table structure corresponding to the second system version into the data table structure of the database to be upgraded, the method further includes: Obtain the newly added fields of the data table structure corresponding to the second system version relative to the data table structure corresponding to the first system version, and set the newly added fields as default values; The detection of whether the system to be upgraded contains a database to be upgraded specifically includes: Determine the database name of the database to be upgraded; Query the database file in the project directory of the system to be upgraded that corresponds to the database name; If a database file corresponding to the database name exists, then the database to be upgraded exists in the system to be upgraded. If no database file corresponding to the database name exists, then the database to be upgraded does not exist in the system to be upgraded. After synchronizing the data table structure with the system to be upgraded and initializing the database of the system to be upgraded, the method further includes: Obtain the configuration file after the database is initialized, and execute the SQL statements preset for each initial data in the configuration file to create the database corresponding to the database to be upgraded.
2. A system upgrade device based on the Go language, characterized in that, The device includes: The detection unit is used to start the system to be upgraded based on a preset program and detect whether the system to be upgraded has a database to be upgraded. An initialization unit is used to initialize the database of the system to be upgraded based on the Go language if the database does not exist. The comparison unit is used to, if present, obtain the first system version in the database to be upgraded and the second system version of the system to be upgraded corresponding to the database to be upgraded, and compare the first system version with the second system version. An upgrade unit is configured to, if it is determined that the first system version and the second system version are different, and the second system version is greater than the first system version, determine the corresponding changed number table structure in the system based on the Go language, and upgrade the database to be upgraded based on the changed number table structure. The database initialization of the system to be upgraded is performed using the Go programming language, specifically including: Obtain the pre-defined data table structure in the xorm framework of the Go language; Synchronize the data table structure with the system to be upgraded to initialize the database of the system to be upgraded. Before obtaining the pre-defined data table structure in the Go language's XORM framework, the process also includes: Determine the database name corresponding to the second system version of the system to be upgraded; Retrieve the custom target field corresponding to the database name based on a preset SQL statement; Obtain a pre-set data table structure template, fill the database name and the custom target field into the corresponding positions in the data table structure template, and obtain the pre-set data table structure; Based on the Go language, the corresponding changed number table structure in the system is determined, and the database to be upgraded is upgraded based on the changed number table structure, specifically including: Obtain the data table structure corresponding to the second system version; Determine whether the data table structure corresponding to the second system version is the same as the data table structure corresponding to the first system version; If not, then based on the sync function in the xorm framework of the Go language, the changed data table structure corresponding to the second system version will be synchronized to the data table structure of the database to be upgraded. Based on the `sync` function in the XORM framework of the Go language, after synchronizing the changed data table structure corresponding to the second system version into the data table structure of the database to be upgraded, the process further includes: Obtain the newly added fields of the data table structure corresponding to the second system version relative to the data table structure corresponding to the first system version, and set the newly added fields as default values; The detection of whether the system to be upgraded contains a database to be upgraded specifically includes: Determine the database name of the database to be upgraded; Query the database file in the project directory of the system to be upgraded that corresponds to the database name; If a database file corresponding to the database name exists, then the database to be upgraded exists in the system to be upgraded. If no database file corresponding to the database name exists, then the database to be upgraded does not exist in the system to be upgraded. After synchronizing the data table structure with the system to be upgraded and initializing the database of the system to be upgraded, the process further includes: Obtain the configuration file after the database is initialized, and execute the SQL statements preset for each initial data in the configuration file to create the database corresponding to the database to be upgraded.
3. A system upgrade device based on the Go programming language, characterized in that, The device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enable the at least one processor to: The system to be upgraded is started based on a preset program, and the system is checked to see if there is a database to be upgraded in the system. If it does not exist, the database of the system to be upgraded will be initialized using the Go language; If they exist, obtain the first system version in the database to be upgraded and the second system version of the system to be upgraded corresponding to the database to be upgraded, and compare the first system version with the second system version. If it is determined that the first system version and the second system version are different, and the second system version is greater than the first system version, then the corresponding changed data table structure in the system is determined based on the Go language, and the database to be upgraded is upgraded based on the changed data table structure. The database initialization of the system to be upgraded is performed using the Go programming language, specifically including: Obtain the pre-defined data table structure in the xorm framework of the Go language; Synchronize the data table structure with the system to be upgraded to initialize the database of the system to be upgraded. Before obtaining the pre-defined data table structure in the Go language's XORM framework, the process also includes: Determine the database name corresponding to the second system version of the system to be upgraded; Retrieve the custom target field corresponding to the database name based on a preset SQL statement; Obtain a pre-set data table structure template, fill the database name and the custom target field into the corresponding positions in the data table structure template, and obtain the pre-set data table structure; Based on the Go language, the corresponding changed number table structure in the system is determined, and the database to be upgraded is upgraded based on the changed number table structure, specifically including: Obtain the data table structure corresponding to the second system version; Determine whether the data table structure corresponding to the second system version is the same as the data table structure corresponding to the first system version; If not, then based on the sync function in the xorm framework of the Go language, the changed data table structure corresponding to the second system version will be synchronized to the data table structure of the database to be upgraded. Based on the `sync` function in the XORM framework of the Go language, after synchronizing the changed data table structure corresponding to the second system version into the data table structure of the database to be upgraded, the process further includes: Obtain the newly added fields of the data table structure corresponding to the second system version relative to the data table structure corresponding to the first system version, and set the newly added fields as default values; The detection of whether the system to be upgraded contains a database to be upgraded specifically includes: Determine the database name of the database to be upgraded; Query the database file in the project directory of the system to be upgraded that corresponds to the database name; If a database file corresponding to the database name exists, then the database to be upgraded exists in the system to be upgraded. If no database file corresponding to the database name exists, then the database to be upgraded does not exist in the system to be upgraded. After synchronizing the data table structure with the system to be upgraded and initializing the database of the system to be upgraded, the process further includes: Obtain the configuration file after the database is initialized, and execute the SQL statements preset for each initial data in the configuration file to create the database corresponding to the database to be upgraded.
4. A non-volatile storage medium storing computer-executable instructions, characterized in that, The computer-executable instructions include: The system to be upgraded is started based on a preset program, and the system is checked to see if there is a database to be upgraded in the system. If it does not exist, the database of the system to be upgraded will be initialized using the Go language; If they exist, obtain the first system version in the database to be upgraded and the second system version of the system to be upgraded corresponding to the database to be upgraded, and compare the first system version with the second system version. If it is determined that the first system version and the second system version are different, and the second system version is greater than the first system version, then the corresponding changed data table structure in the system is determined based on the Go language, and the database to be upgraded is upgraded based on the changed data table structure. The database initialization of the system to be upgraded is performed using the Go programming language, specifically including: Obtain the pre-defined data table structure in the xorm framework of the Go language; Synchronize the data table structure with the system to be upgraded to initialize the database of the system to be upgraded. Before obtaining the pre-defined data table structure in the Go language's XORM framework, the process also includes: Determine the database name corresponding to the second system version of the system to be upgraded; Retrieve the custom target field corresponding to the database name based on a preset SQL statement; Obtain a pre-set data table structure template, fill the database name and the custom target field into the corresponding positions in the data table structure template, and obtain the pre-set data table structure; Based on the Go language, the corresponding changed number table structure in the system is determined, and the database to be upgraded is upgraded based on the changed number table structure, specifically including: Obtain the data table structure corresponding to the second system version; Determine whether the data table structure corresponding to the second system version is the same as the data table structure corresponding to the first system version; If not, then based on the sync function in the xorm framework of the Go language, the changed data table structure corresponding to the second system version will be synchronized to the data table structure of the database to be upgraded. Based on the `sync` function in the XORM framework of the Go language, after synchronizing the changed data table structure corresponding to the second system version into the data table structure of the database to be upgraded, the process further includes: Obtain the newly added fields of the data table structure corresponding to the second system version relative to the data table structure corresponding to the first system version, and set the newly added fields as default values; The detection of whether the system to be upgraded contains a database to be upgraded specifically includes: Determine the database name of the database to be upgraded; Query the database file in the project directory of the system to be upgraded that corresponds to the database name; If a database file corresponding to the database name exists, then the database to be upgraded exists in the system to be upgraded. If no database file corresponding to the database name exists, then the database to be upgraded does not exist in the system to be upgraded. After synchronizing the data table structure with the system to be upgraded and initializing the database of the system to be upgraded, the process further includes: Obtain the configuration file after the database is initialized, and execute the SQL statements preset for each initial data in the configuration file to create the database corresponding to the database to be upgraded.
Citation Information
Patent Citations
Method and equipment for upgrading database structure
CN105335436A
Database creation method and system
CN110968565A