CN116049207A - Application SQL script processing method and device, processor and electronic equipment - Google Patents

Application SQL script processing method and device, processor and electronic equipment Download PDF

Info

Publication number
CN116049207A
CN116049207A CN202310063821.9A CN202310063821A CN116049207A CN 116049207 A CN116049207 A CN 116049207A CN 202310063821 A CN202310063821 A CN 202310063821A CN 116049207 A CN116049207 A CN 116049207A
Authority
CN
China
Prior art keywords
sql script
application program
configuration file
version information
application
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310063821.9A
Other languages
Chinese (zh)
Inventor
滕召奇
郭利娟
伍思佳
吴雄飞
孙海华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hillstone Networks Co Ltd
Original Assignee
Hillstone Networks Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hillstone Networks Co Ltd filed Critical Hillstone Networks Co Ltd
Priority to CN202310063821.9A priority Critical patent/CN116049207A/en
Publication of CN116049207A publication Critical patent/CN116049207A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/214Database migration support
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/219Managing data history or versioning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Software Systems (AREA)
  • Mathematical Physics (AREA)
  • Computational Linguistics (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses an application SQL script processing method, an application SQL script processing device, a processor and electronic equipment. The method comprises the following steps: after the application program is started, executing an initializing SQL script on the application program to obtain a configuration file of the application program; executing the upgrading SQL script on the application program according to the configuration file, and acquiring version information of the upgrading SQL script; according to the version information of the upgrade SQL script, obtaining an updated configuration file; and when the next starting of the application program is detected, executing the upgrading SQL script corresponding to the application program according to the updated configuration file. According to the method and the device, the problem that in the related technology, in the development process of application software, a large number of database upgrading SQL scripts containing different subsystems or different versions of application programs are generated, so that developers are difficult to maintain the upgrading SQL scripts related to the application programs is solved.

Description

Application SQL script processing method and device, processor and electronic equipment
Technical Field
The present invention relates to the technical field of computer software, and in particular, to a method and apparatus for processing an SQL script of an application program, a processor, and an electronic device.
Background
At present, when SQL scripts written in a management database language are used, SQL scripts corresponding to an application program are often maintained through the bypass software, but when a plurality of subsystems and a plurality of versions exist in the application program, a large number of SQL scripts are generated by the versions corresponding to each subsystem, so that the workload of maintaining the SQL scripts of the application program by a developer through the bypass software is increased in a linear manner, a large amount of time and effort are consumed, and the working efficiency is low. In addition, because the bypass software automatically updates the database table structure and the data through the incremental SQL scripts, different SQL scripts may contain SQL scripts of different versions of the application program, so that a developer may need to traverse all SQL scripts when maintaining the application program SQL scripts, and the working efficiency of the developer is reduced. In addition, in order to be compatible with multiple persons when multiple developers commonly develop application programs, the same SQL script is generally used for development and modification, but the Flyway software cannot repeatedly execute the modified SQL script, so that the requirements of the developers are difficult to meet, and the working efficiency of the developers is reduced.
Aiming at the problem that in the related art, in the development process of application software, a large number of database upgrading SQL scripts containing different subsystems or different versions of application programs are generated, so that developers are difficult to maintain the upgrading SQL scripts related to the application programs, no effective solution is proposed at present.
Disclosure of Invention
The main purpose of the application is to provide a method, a device, a processor and an electronic device for processing SQL scripts of an application program, so as to solve the problem that in the related technology, in the development process of the application software, a large number of database upgrading SQL scripts containing different subsystems or different versions of the application program can be generated, and the developer is difficult to maintain the upgrading SQL scripts related to the application program.
To achieve the above object, according to one aspect of the present application, there is provided an application SQL script processing method. The method comprises the following steps: after an application program is started, executing an initializing SQL script on the application program to obtain a configuration file of the application program, wherein the configuration file is used for recording version information of an upgrading SQL script executed when the application program is started each time; executing the upgrading SQL script on the application program according to the configuration file, and acquiring version information of the upgrading SQL script; obtaining an updated configuration file according to the version information of the upgrade SQL script; and when the next starting of the application program is detected, executing the upgrading SQL script corresponding to the application program according to the updated configuration file.
Further, after the application program is started, executing the initializing SQL script on the application program, and obtaining the configuration file of the application program comprises: judging whether the configuration file exists or not; if the configuration file does not exist, executing the initializing SQL script on at least one subsystem of the application program to obtain the configuration file; and if the configuration file exists, acquiring the existing configuration file.
Further, after the application program is started, executing an initializing SQL script on the application program, and before acquiring the configuration file of the application program, the method further comprises: configuring a first file position and a second file position of the application program, wherein the first file position is used for storing the initialization SQL script of at least one subsystem of the application program, and the second file position is used for storing the upgrading SQL script of the application program; and configuring current version information and development version information of the application program, wherein the current version information comprises the application version information of the application program which is released and online, and the development version information is development version information of the application program in a development code stage.
Further, if the configuration file does not exist, executing the initializing SQL script on at least one subsystem of the application program, and obtaining the configuration file includes: searching the initializing SQL script of at least one subsystem at the first file position through a class loader; executing the initializing SQL script at the first file position, and acquiring the current version information of the initializing SQL script; and acquiring the configuration file according to the current version information.
Further, executing the upgrade SQL script on the application program according to the configuration file, and acquiring version information of the upgrade SQL script includes: judging whether a target SQL script exists or not according to the configuration file, wherein the target SQL script refers to the upgrading SQL script with version information of the upgrading SQL script in the second file position higher than that of the latest version information in the configuration file; if the target SQL script exists in the second file position, executing the target SQL script on the application program, and obtaining version information of the upgrading SQL script according to the latest version information of the target SQL script; and if the target SQL script does not exist in the second file position, executing the target SQL script on the application program according to the configuration file and the development version information.
Further, if the target SQL script does not exist in the second file location, executing the target SQL script on the application program according to the configuration file and the development version information includes: if the target SQL script does not exist in the second file position, judging whether the development version information is empty or not; if the development version information is not null, continuing to execute the upgrading SQL script corresponding to the highest version in the configuration file for the application program; and if the development version information is empty, the SQL script is not executed on the application program.
Further, after obtaining the updated configuration file according to the version information of the upgrade SQL script, the method further comprises: if the application program is detected to release a new version, acquiring the upgrading SQL script of the new version at the second file position; updating the new version of upgrade SQL script into the initialization SQL script of the corresponding subsystem of the first file position, and setting the development version information to be null.
To achieve the above object, according to another aspect of the present application, there is provided an application SQL script processing apparatus. The device comprises: the first acquisition unit is used for executing an initializing SQL script on the application program after the application program is started to acquire a configuration file of the application program, wherein the configuration file is used for recording version information of the upgrading SQL script executed when the application program is started each time; the second obtaining unit is used for executing the upgrading SQL script on the application program according to the configuration file and obtaining version information of the upgrading SQL script; the third acquisition unit is used for obtaining an updated configuration file according to the version information of the upgrade SQL script; and the execution unit is used for executing the upgrading SQL script corresponding to the application program according to the updated configuration file when the next starting of the application program is detected.
Further, the first acquisition unit includes: a first judging subunit, configured to judge whether the configuration file exists; the first acquisition subunit is used for executing the initializing SQL script on at least one subsystem of the application program if the configuration file does not exist, so as to obtain the configuration file; and the second acquisition subunit is used for acquiring the existing configuration file if the configuration file exists.
Further, the apparatus further comprises: the first configuration unit is used for executing an initialization SQL script on the application program after the application program is started, and configuring a first file position and a second file position of the application program before a configuration file of the application program is acquired, wherein the first file position is used for storing the initialization SQL script of at least one subsystem of the application program, and the second file position is used for storing the upgrading SQL script of the application program; the second configuration unit is used for configuring the current version information and the development version information of the application program, wherein the current version information comprises the application version information of the application program which is released online, and the development version information is the development version information of the application program which is in a development code stage.
Further, the first acquisition subunit includes: the query module is used for searching the initialized SQL script of at least one subsystem at the first file position through the class loader; the first acquisition module is used for executing the initializing SQL script at the first file position and acquiring the current version information of the initializing SQL script; and the second acquisition module is used for acquiring the configuration file according to the current version information.
Further, the second acquisition unit includes: a second judging subunit, configured to judge whether a target SQL script exists according to the configuration file, where the target SQL script refers to an upgrade SQL script in the second file location, where version information of the upgrade SQL script is higher than version information of the latest version information in the configuration file; the third obtaining subunit is configured to execute the target SQL script on the application program if the target SQL script exists in the second file location, and obtain version information of the upgraded SQL script according to latest version information of the target SQL script; and the execution subunit is used for executing the target SQL script on the application program according to the configuration file and the development version information if the target SQL script does not exist in the second file position.
Further, the execution subunit further includes: the first judging module is used for judging whether the development version information is empty or not if the target SQL script does not exist in the second file position; the execution module is used for continuing to execute the upgrading SQL script corresponding to the highest version in the configuration file for the application program if the development version information is not null; and the second judging module is used for not executing the SQL script on the application program if the development version information is empty.
Further, the apparatus further comprises: a fourth obtaining unit, configured to obtain, after obtaining an updated configuration file according to version information of the upgrade SQL script, if it is detected that the application program issues a new version, obtain the upgrade SQL script of the new version at the second file location; and the updating unit is used for updating the updated SQL script of the new version into the initialized SQL script of the corresponding subsystem of the first file position, and setting the development version information to be null.
To achieve the above object, according to one aspect of the present application, there is provided a processor for running a program, wherein the program runs to execute the method for processing the SQL script of the application program according to any one of the above.
To achieve the above object, according to one aspect of the present application, there is provided an electronic device including one or more processors and a memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement any one of the above application SQL script processing methods.
Through the application, the following steps are adopted: after an application program is started, executing an initializing SQL script on the application program to obtain a configuration file of the application program, wherein the configuration file is used for recording version information of an upgrading SQL script executed when the application program is started each time; executing the upgrading SQL script on the application program according to the configuration file, and acquiring version information of the upgrading SQL script; obtaining an updated configuration file according to the version information of the upgrade SQL script; when the next starting of the application program is detected, the upgrading SQL script corresponding to the application program is executed according to the updated configuration file, so that the problem that in the related technology, in the development process of the application software, a large number of database upgrading SQL scripts containing different subsystems or different versions of the application program are generated, and a developer is difficult to maintain the upgrading SQL script related to the application program is solved. The process of deploying the application program database is separated into the process of initializing the application program and the process of upgrading the application program, and the SQL script written by the developer is maintained according to the configuration file, so that the maintenance cost of the developer for maintaining a plurality of SQL scripts corresponding to a plurality of subsystems of the application program is reduced, and the effect of improving the working efficiency of the developer is further achieved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application, illustrate and explain the application and are not to be construed as limiting the application. In the drawings:
FIG. 1 is a flow chart of an application SQL script processing method provided in accordance with an embodiment of the present application;
FIG. 2 is a schematic diagram I of an alternative application SQL script processing method provided in accordance with embodiments of the present application;
FIG. 3 is a second schematic diagram of an alternative application SQL script processing method provided according to an embodiment of the application;
FIG. 4 is a third schematic diagram of an alternative application SQL script processing method provided according to an embodiment of the application;
FIG. 5 is a schematic diagram IV of an alternative application SQL script processing method provided according to an embodiment of the application;
FIG. 6 is a schematic diagram five of an alternative application SQL script processing method provided in accordance with embodiments of the present application;
FIG. 7 is a diagram six of an alternative application SQL script processing method provided in accordance with embodiments of the present application;
fig. 8 is a schematic diagram of an application SQL script processing apparatus provided according to an embodiment of the present application.
Detailed Description
It should be noted that, in the case of no conflict, the embodiments and features in the embodiments may be combined with each other. The present application will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
In order to make the present application solution better understood by those skilled in the art, the following description will be made in detail and with reference to the accompanying drawings in the embodiments of the present application, it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, shall fall within the scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of the present application and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate in order to describe the embodiments of the present application described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
For convenience of description, the following will describe some terms or terms related to the embodiments of the present application:
database migration (Database Migration): with different demands of clients on application programs, developers are required to develop and perfect codes for controlling the running of the application programs continuously. In the process of continuously completing one application program, each time a developer completes modification of the application program, the application program performs iteration, and when more functions need to be realized in the application program, the next iteration is performed on the current version of the application program. In the process of application program iteration, a developer can make corresponding modifications to the data structure of the database, such as adding a data table, adding a field to the data table, modifying a field of the data table, and the like. Each change of the database is referred to as a database migration.
Class loader (ClassLoader): the class loader is a kind of loader that loads Java classes into a Java virtual machine. Class loaders are different from ordinary programs in that a program written based on the Java language (i.e., a file prefixed with ". Class") is not an executable program local to a computer. When running a program written based on the Java language, a JVM (Java virtual machine) is firstly run, then Java classes are loaded into the Java virtual machine to run, and the part of codes responsible for loading the Java classes is called class loader.
Flyway software: the bypass software is a database version management software of open source. The bypass software can manage and track the change records of the database independently of the application program, meanwhile, the bypass software can automatically upgrade the version of the database without complex configuration, in addition, the database migration can be written into an SQL script, and the database migration can be realized by running the SQL script through the bypass software.
Example 1
The present invention is described below in connection with preferred implementation steps, and fig. 1 is a flowchart of an application SQL script processing method provided according to an embodiment of the present application, as shown in fig. 1, and the method includes the following steps:
step S101, after the application program is started, executing an initializing SQL script to the application program, and obtaining a configuration file of the application program, wherein the configuration file is used for recording version information of the upgrading SQL script executed when the application program is started each time.
When a developer develops an application, the developer is required to develop and perfect the application continuously along with different requirements of clients on the application. In the process of application program iteration, a developer needs to make multiple modifications to the data structure and data of the database by using the SQL script, a large number of SQL scripts for modifying the database can be generated, and meanwhile, the application program possibly comprises a plurality of subsystems, so that the number of SQL script files related to the application program is further increased.
For example, as shown in fig. 2, the SQL script generated in the development process includes three blocks in fig. 2, and the SQL script generated after the application program is upgraded is shown in sequence from left to right: the leftmost is the first published online application, which contains three versions of application corresponding to the SQL scripts of the three subsystems, namely V1.1_Module1.sql, V1.2_Module2.sql, and V1.3_Module3.sql, respectively, where V1.1_Module1.sql represents the SQL script of subsystem one of the V1.1 version application (i.e., module 1), V1.2_Module2.sql represents the SQL script of subsystem two of the V1.2 version application (i.e., module 2), and V1.3_Module3.sql represents the SQL script of subsystem three of the V1.3 version application (i.e., module 3). Six SQL scripts are obtained after one upgrade of the application programs corresponding to the three SQL scripts, nine SQL scripts are obtained after two upgrades, the nine SQL scripts respectively comprise SQL scripts of different versions and different modules, if a developer needs to inquire the SQL scripts of the subsystem 3, three files need to be traversed for inquiry, and the efficiency of the inquiry process is low.
In order to switch the database to the version corresponding to the application program and simultaneously facilitate the developer to maintain the SQL script related to the application program, in the embodiment, when the application program is started on an electronic device for the first time, the process of configuring the application program database is divided into two processes, namely an initialization process and an upgrading process, wherein the initialization process is responsible for switching the database to the version which is stably on line, and the upgrading process is responsible for processing the database which is executed with the initialization SQL script according to actual conditions, so as to obtain the database required by the developer.
In this embodiment, in order to make a developer more flexible and convenient to maintain SQL scripts of multiple subsystems of an application program, the application program needs to be initialized, that is, the application program executes the initialized SQL scripts corresponding to the multiple subsystems. After the initializing SQL script is executed, a configuration file is obtained from the initializing SQL script, so that the database corresponding to the application program can be conveniently updated later.
Step S102, executing the upgrade SQL script on the application program according to the configuration file, and acquiring version information of the upgrade SQL script.
In this embodiment, in order to configure a corresponding database for an application program, upgrade the database to a database version required by a developer, after initializing the application program, it is necessary to continue executing an upgrade SQL script for the application program, and obtain version information of the upgrade SQL script.
And step S103, obtaining an updated configuration file according to the version information of the upgrade SQL script.
Step S104, when the next starting of the application program is detected, executing the upgrading SQL script corresponding to the application program according to the updated configuration file.
After the database is upgraded to the version of the database required by the developer, the configuration file needs to be modified in time, so that when the application program is restarted subsequently, the correct SQL script is executed according to the updated configuration file to process the database.
In summary, according to the application SQL script processing method provided by the embodiment of the application, after the application is started, the application executes the initialized SQL script to obtain the configuration file of the application, wherein the configuration file is used for recording version information of the upgraded SQL script executed when the application is started each time; executing the upgrading SQL script on the application program according to the configuration file, and acquiring version information of the upgrading SQL script; according to the version information of the upgrade SQL script, obtaining an updated configuration file; when the next starting of the application program is detected, the upgrading SQL script corresponding to the application program is executed according to the updated configuration file, and the problem that in the related technology, in the development process of the application software, a large number of database upgrading SQL scripts containing different subsystems or different versions of the application program are generated, so that a developer is difficult to maintain the upgrading SQL script related to the application program is solved. The process of deploying the application program database is separated into the process of initializing the application program and the process of upgrading the application program, and the SQL script written by the developer is maintained according to the configuration file, so that the maintenance cost of the developer for maintaining the SQL script corresponding to a plurality of subsystems of the application program is reduced, and the effect of improving the working efficiency of the developer is further achieved.
Optionally, in the application SQL script processing method provided in the embodiment of the present application, after the application is started, executing the initialization SQL script on the application, and obtaining the configuration file of the application includes: judging whether a configuration file exists or not; if the configuration file does not exist, executing an initializing SQL script on at least one subsystem of the application program to obtain the configuration file; if the configuration file exists, the existing configuration file is obtained.
In this embodiment, in order to make a developer clearly understand an initialized SQL script of at least one subsystem included in an application program while switching the database to a version corresponding to the application program, it is necessary to switch the database to a version that has been stably online first: firstly, judging whether a configuration file exists in an application program or not; if the application program does not have the configuration file, determining that the application program does not complete the initialization process, and also does not have a database required for ensuring the normal operation of the application program, wherein the initialization process of the application program is required, namely, at least one subsystem of the application program executes a corresponding initialization SQL script, version information corresponding to the executed initialization SQL script is written into the configuration file, and the process of initializing the application program is completed; if the application program has the configuration file, determining that the application program has completed the initialization process, and acquiring the existing configuration file so as to execute the process of upgrading the application program subsequently.
By executing the plurality of initializing SQL scripts to initialize at least one subsystem of the application program, updating the current database to the database corresponding to the application program with the online version, and acquiring the configuration file according to the initializing SQL scripts, the method and the device enable a developer to clearly know the database structures and specific data of the plurality of subsystems of the application program, and further achieve the effect of reducing maintenance cost of the developer for maintaining the SQL scripts corresponding to the plurality of subsystems of the application program.
Optionally, in the method for processing an application SQL script provided in the embodiment of the present application, after an application is started, before the application executes an initialization SQL script to obtain a configuration file of the application, the method further includes: configuring a first file position and a second file position of the application program, wherein the first file position is used for storing an initialization SQL script of at least one subsystem of the application program, and the second file position is used for storing an upgrade SQL script of the application program; the method comprises the steps of configuring current version information and development version information of an application program, wherein the current version information comprises application version information of the application program which is released and online, and the development version information is development version information of the application program in a development code stage.
In order to facilitate subsequent initialization processing and upgrade processing of the application program, it is necessary to configure an SQL script (i.e., a first file location) for storing at least one subsystem corresponding to the application program before initializing the application program, configure an SQL script (i.e., a second file location) for storing different versions of the application program, and configure current version information and development version information of the application program. For example, the file structures of the first file location and the second file location are shown in fig. 3, where the folder path of the first file location is resources/db/init, and the folder path of the second file location is resources/db/division.
The first file position and the second file position of the application program are configured, and the current version information and the development version information of the application program are configured, so that the subsequent processing of the application program is facilitated, the initialization processing and the upgrading processing of the application program are performed according to the judging result, the maintenance cost of the related SQL script for maintaining and developing the application program by a developer is reduced, and the effect of improving the efficiency of maintaining and developing the application program by the developer is further achieved.
Optionally, in the method for processing an SQL script of an application program provided in the embodiment of the present application, if a configuration file does not exist, executing an initialization SQL script on at least one subsystem of the application program, and obtaining the configuration file includes: searching an initializing SQL script of at least one subsystem in a first file position through a class loader; executing an initializing SQL script in a first file position, and acquiring current version information of the initializing SQL script; and acquiring a configuration file according to the current version information.
In the prior art, when an application program consisting of a plurality of subsystems is developed, an incremental update SQL script is often used to maintain SQL scripts generated in the development process, further, when the number of iterative versions of the application program and the number of subsystems are gradually increased, the number of SQL scripts related to the application program is multiplied, and meanwhile, the SQL scripts containing a plurality of iterative versions or a plurality of subsystems in one incremental update SQL script also appear, so that a developer is difficult to maintain the SQL scripts related to the application program.
In this embodiment, in order for a developer to conveniently maintain or develop SQL scripts of a plurality of subsystems related to an application program, an initialization and an upgrade are required for a database corresponding to the application program, where an initialization process for the database corresponding to the application program is as follows: firstly, searching an initializing SQL script corresponding to at least one subsystem in a first file position through a class loader; then executing an initializing SQL script corresponding to at least one subsystem found in the first file position, and obtaining the current version information of the initializing SQL script; and then acquiring a configuration file according to the current version information, wherein the content of the configuration file is shown in a table 1, and the table 1 contains 0003 version information corresponding to the initializing SQL script.
Table 1: configuration file generated after application program initialization
id version file md5
1 0003
By carrying out initialization processing on the application program comprising a plurality of subsystems, and storing the initialization SQL script related to the application program into different files according to the subsystems corresponding to the initialization SQL script, the method is beneficial to a developer to conveniently maintain or develop the SQL script of the plurality of subsystems related to the application program, and realizes the reduction of maintenance cost of the developer to maintain and develop the related SQL script of the application program, thereby achieving the effect of improving the working efficiency of the developer.
Optionally, in the method for processing an SQL script of an application program provided in the embodiment of the present application, executing an upgrade SQL script on the application program according to a configuration file, and obtaining version information of the upgrade SQL script includes: judging whether a target SQL script exists or not according to the configuration file, wherein the target SQL script refers to an upgrade SQL script with version information of the upgrade SQL script in a second file position higher than that of the latest version information in the configuration file; if the target SQL script exists in the second file position, executing the target SQL script by the application program, obtaining version information of the upgrading SQL script according to the latest version information of the target SQL script, wherein the version information obtained according to the upgrading SQL script is shown in a table 2, the table 2 comprises 0003 version information corresponding to the initializing SQL script and 0004 version information corresponding to the upgrading SQL script, the 'U00045.4.0.sql' is the file name of the upgrading SQL script file, and the 'abcd 5' is an md5 check code for checking the file; and if the target SQL script does not exist in the second file position, executing the target SQL script on the application program according to the configuration file and the development version information.
Table 2: upgrading version information corresponding to SQL script
id version file md5
1 0003
2 0004 U0004_5.4.0.sql abcd5
In this embodiment, in order for a developer to conveniently maintain or develop SQL scripts of a plurality of subsystems related to an application, after initializing a database corresponding to the application, it is necessary to continue the upgrade processing of the database: firstly judging whether a target SQL script exists in a second file position, wherein the version information of the target SQL script is higher than the latest version information recorded in a configuration file; if the target SQL script exists, determining that the current version of the database corresponding to the application program is not the latest version required by the developer, continuing to execute the target SQL script on the database, and acquiring version information of the upgrade SQL script; if the target SQL script does not exist, determining that the current version of the database corresponding to the application program is the latest version developed by the developer, and continuing to process the application program according to the configuration file and the development version information.
By reading the configuration file, judging whether the target SQL script exists in the second file position, and carrying out different treatments on the application program according to the judging result, the effects of separating the initialization SQL script of the application program and upgrading the SQL script are realized, the SQL script can be flexibly executed on the application program according to the actual condition of the application program, and the effect of improving the efficiency of maintaining and developing the related SQL script of the application program by a developer is further achieved.
Optionally, in the method for processing an application SQL script provided in the embodiment of the present application, if the target SQL script does not exist in the second file location, executing the target SQL script on the application according to the configuration file and the development version information includes: if the target SQL script does not exist in the second file position, judging whether the development version information is empty or not; if the development version information is not null, continuing to execute the upgrade SQL script corresponding to the highest version in the configuration file for the application program; if the development version information is null, the SQL script is not executed on the application.
In the development stage, a plurality of developers may modify the database corresponding to the application program together, and in this embodiment, in order to support that after the plurality of developers modify the SQL script in the development stage, the modified SQL script can be repeatedly executed when the program is started each time, so as to ensure that the plurality of developers can repeatedly test or modify the code corresponding to the application program in the development stage, it is necessary to determine whether the application program is in the development stage according to the configured development version information. If the development version information is not null, confirming that the application program is in a development stage, and continuing to execute the upgrade SQL script corresponding to the highest version in the configuration file for the application program; if the development version information is empty, the application program is confirmed not to be in the development stage, namely, the upgrading SQL script corresponding to the highest version in the configuration file is executed, so that the SQL script is not executed on the application program any more.
For example, as shown in fig. 4, a schematic diagram of developing a version V4 of an application program by multiple developers is that four developers are respectively responsible for SQL update statements of one functional module, and when restarting the application program in the development process, the V4.SQL script file is repeatedly executed.
By setting the development mode for the application program, the method and the device can adaptively control whether the SQL script is repeatedly executed by the application program or not when the application program is started according to the specific development state of the developer, so that the effect of improving the working efficiency of the developer is achieved.
Optionally, in the method for processing an application SQL script provided in the embodiment of the present application, after obtaining an updated configuration file according to version information of an upgraded SQL script, the method further includes: if the application program is detected to release the new version, acquiring an upgrade SQL script of the new version at a second file position; updating the new version of upgrade SQL script into the initialization SQL script of the corresponding subsystem of the first file position, and setting the development version information to be null.
In order to facilitate the management of multiple subsystems and multiple versions of upgrade SQL scripts by a developer, after an application program issues a new version, the new version of upgrade SQL script of the multiple subsystems needs to be acquired at a second file position; and adding the newly added upgrading SQL script of the plurality of subsystems in the new version into the initializing SQL script corresponding to the plurality of subsystems in the first file position, and setting the development version information to be null. For example, after the application program issues the new version 00005, the configuration file after restarting the application program update is shown in table 3, and after the application program issues the new version 00005, the version information corresponding to the version 00005 is written in the configuration file after restarting the application program.
Table 3: new version of application program, configuration file obtained after restarting application program
id version file md5
1 0003
2 0004 U0004_5.4.0.sql abcd5
3 00005 U0005_5.5.0.sql abcd6
The new upgrading SQL scripts of the plurality of subsystems of the new version of the application program are added to the initializing SQL scripts corresponding to the plurality of subsystems in the first file position, so that developers can manage the upgrading SQL scripts corresponding to the plurality of subsystems and the upgrading SQL scripts corresponding to the plurality of versions more clearly and intuitively.
Alternatively, in this embodiment, the prior art incremental SQL script procedure maintained by the Flyway software may be as shown in fig. 5, 6 and 7, for example, three SQL script files in the current version of the application program, as shown in fig. 5, are v1.sql, v2.sql, v3.sql, respectively; then, as shown in fig. 6, the Flyway software sequentially executes three SQL scripts of v1.sql, v2.sql and v3.sql through judgment, and records the executed SQL scripts, file names of the SQL scripts, md5 values corresponding to the SQL scripts and other information in a data table after the execution is finished; when the application program issues a new version, the upgrade SQL script is v4.sql, the gateway software judges according to the latest version of the database, if the latest version of the database is V3, the upgrade SQL script with the version lower than or equal to V3 is not executed any more, but v4.sql is executed, and version information corresponding to v4.sql is updated to the data table, as shown in fig. 7.
It should be noted that the steps illustrated in the flowcharts of the figures may be performed in a computer system such as a set of computer executable instructions, and that although a logical order is illustrated in the flowcharts, in some cases the steps illustrated or described may be performed in an order other than that illustrated herein.
Example 2
The embodiment of the application also provides an application SQL script processing device, and it should be noted that the application SQL script processing device of the embodiment of the application may be used to execute the application SQL script processing method provided in embodiment 1 of the application. The following describes an application SQL script processing apparatus provided in an embodiment of the present application.
Fig. 8 is a schematic diagram of an application SQL script processing apparatus according to an embodiment of the present application. As shown in fig. 8, the apparatus includes: a first acquisition unit 801, a second acquisition unit 802, a third acquisition unit 803, and an execution unit 804.
The first obtaining unit 801 is configured to execute an initialization SQL script for an application program after the application program is started, and obtain a configuration file of the application program, where the configuration file is used to record version information of an upgrade SQL script executed when the application program is started each time.
When a developer develops an application, the developer is required to develop and perfect the application continuously along with different requirements of clients on the application. In the process of application program iteration, a developer needs to make multiple modifications to the data structure and data of the database by using the SQL script, a large number of SQL scripts for modifying the database can be generated, and meanwhile, the application program possibly comprises a plurality of subsystems, so that the number of SQL script files related to the application program is further increased. In order to switch the database to the version corresponding to the application program and simultaneously facilitate the developer to maintain the SQL script related to the application program, in the embodiment, when the application program is started on an electronic device for the first time, the process of configuring the application program database is divided into two processes, namely an initialization process and an upgrading process, wherein the initialization process is responsible for switching the database to the version which is stably on line, and the upgrading process is responsible for processing the database which is executed with the initialization SQL script according to actual conditions, so as to obtain the database required by the developer.
In this embodiment, in order to make a developer more flexible and convenient to maintain SQL scripts of multiple subsystems of an application program, the application program needs to be initialized, that is, the application program executes the initialized SQL scripts corresponding to the multiple subsystems. After the initializing SQL script is executed, a configuration file is obtained from the initializing SQL script through the first obtaining unit 801, so that the database corresponding to the application program can be conveniently updated later.
The second obtaining unit 802 is configured to execute the upgrade SQL script on the application program according to the configuration file, and obtain version information of the upgrade SQL script.
In this embodiment, in order to configure a corresponding database for an application program, upgrade the database to a database version required by a developer, after initializing the application program, the application program needs to continue to execute the upgrade SQL script, and the second obtaining unit 802 is used to obtain version information of the upgrade SQL script.
And a third obtaining unit 803, configured to obtain an updated configuration file according to version information of the upgrade SQL script.
The execution unit 804 is configured to execute the upgrade SQL script corresponding to the application program according to the updated configuration file when the next start of the application program is detected.
After upgrading the database to the version of the database required by the developer, the modified configuration file needs to be acquired by using the third acquiring unit 803 in time, so that when the application program is restarted subsequently, the correct SQL script is executed by the executing unit 804 to process the database according to the updated configuration file.
In summary, in the application SQL script processing apparatus provided in the embodiments of the present application, through the first obtaining unit 801, the application is configured to execute an initialization SQL script after the application is started, and obtain a configuration file of the application, where the configuration file is used to record version information of an upgrade SQL script executed when the application is started each time; a second obtaining unit 802, configured to execute the upgrade SQL script on the application program according to the configuration file, and obtain version information of the upgrade SQL script; a third obtaining unit 803, configured to obtain an updated configuration file according to version information of the upgrade SQL script; the execution unit 804 is configured to execute the upgrade SQL script corresponding to the application program according to the updated configuration file when the next start of the application program is detected, so that the problem that in the related art, in the development process of the application software, a large number of database upgrade SQL scripts including different subsystems or different versions of the application program are generated, and it is difficult for a developer to maintain the upgrade SQL script related to the application program is solved. The process of deploying the application program database is separated into the process of initializing the application program and the process of upgrading the application program, and the SQL script written by the developer is maintained according to the configuration file, so that the maintenance cost of the developer for maintaining the SQL script corresponding to a plurality of subsystems of the application program is reduced, and the effect of improving the working efficiency of the developer is further achieved.
Optionally, in the application SQL script processing apparatus provided in the embodiment of the present application, the first obtaining unit 801 includes: a first judging subunit, configured to judge whether a configuration file exists; the first acquisition subunit is used for executing an initializing SQL script on at least one subsystem of the application program if the configuration file does not exist, so as to obtain the configuration file; and the second acquisition subunit is used for acquiring the existing configuration file if the configuration file exists.
In this embodiment, in order to make a developer clearly understand an initialized SQL script of at least one subsystem included in an application program while switching the database to a version corresponding to the application program, it is necessary to switch the database to a version that has been stably online first: firstly, judging whether a configuration file exists in an application program or not through a first judging subunit; if the application program does not have the configuration file, determining that the application program does not complete the initialization process, and also does not have a database required for ensuring the normal operation of the application program, wherein the initialization process of the application program is required, namely at least one subsystem of the application program executes a corresponding initialization SQL script, version information corresponding to the executed initialization SQL script is written into the configuration file, the configuration file is obtained through a first obtaining subunit, and the process of initializing the application program is completed; if the application program has the configuration file, determining that the application program has completed the initialization process, and acquiring the existing configuration file by using a second acquisition subunit so as to execute the process of upgrading the application program subsequently.
By executing the plurality of initializing SQL scripts to initialize at least one subsystem of the application program, updating the current database to the database corresponding to the application program with the online version, and acquiring the configuration file according to the initializing SQL scripts, the method and the device enable a developer to clearly know the database structures and specific data of the plurality of subsystems of the application program, and further achieve the effect of reducing maintenance cost of the developer for maintaining the SQL scripts corresponding to the plurality of subsystems of the application program.
Optionally, in the application SQL script processing apparatus provided in the embodiment of the present application, the apparatus further includes: the first configuration unit is used for executing an initializing SQL script to the application program after the application program is started, and configuring a first file position and a second file position of the application program before a configuration file of the application program is acquired, wherein the first file position is used for storing the initializing SQL script of at least one subsystem of the application program, and the second file position is used for storing an upgrading SQL script of the application program; the second configuration unit is used for configuring the current version information and the development version information of the application program, wherein the current version information comprises the application version information of the application program which is released and online, and the development version information is the development version information of the application program in a development code stage.
In order to facilitate the subsequent initialization processing and upgrade processing of the application program, a first configuration unit needs to be used for configuring and storing SQL scripts (i.e., first file positions) corresponding to at least one subsystem included in the application program before the application program is initialized, and a second configuration unit needs to be used for configuring and storing SQL scripts (i.e., second file positions) corresponding to different versions of the application program, and the second configuration unit is used for configuring the current version information and the development version information of the application program.
The first file position and the second file position of the application program are configured, and the current version information and the development version information of the application program are configured, so that the subsequent processing of the application program is facilitated, the initialization processing and the upgrading processing of the application program are performed according to the judging result, the maintenance cost of the related SQL script for maintaining and developing the application program by a developer is reduced, and the effect of improving the efficiency of maintaining and developing the application program by the developer is further achieved.
Optionally, in the application SQL script processing apparatus provided in the embodiment of the present application, the first obtaining subunit includes: the query module is used for searching the initialized SQL script of at least one subsystem at the first file position through the class loader; the first acquisition module is used for executing the initializing SQL script at the first file position and acquiring the current version information of the initializing SQL script; the second acquisition module is used for acquiring the configuration file according to the current version information.
In the prior art, when an application program consisting of a plurality of subsystems is developed, an incremental update SQL script is often used to maintain SQL scripts generated in the development process, further, when the number of iterative versions of the application program and the number of subsystems are gradually increased, the number of SQL scripts related to the application program is multiplied, and meanwhile, the SQL scripts containing a plurality of iterative versions or a plurality of subsystems in one incremental update SQL script also appear, so that a developer is difficult to maintain the SQL scripts related to the application program.
In this embodiment, in order for a developer to conveniently maintain or develop SQL scripts of a plurality of subsystems related to an application program, an initialization and an upgrade are required for a database corresponding to the application program, where an initialization process for the database corresponding to the application program is as follows: firstly, searching an initializing SQL script corresponding to at least one subsystem in a first file position by using a class loader through a query module; then executing an initializing SQL script corresponding to at least one subsystem found in the first file position, and acquiring current version information of the initializing SQL script through a first acquisition module; and then acquiring the configuration file by using a second acquisition module according to the current version information.
By carrying out initialization processing on the application program comprising a plurality of subsystems, and storing the initialization SQL script related to the application program into different files according to the subsystems corresponding to the initialization SQL script, the method is beneficial to a developer to conveniently maintain or develop the SQL script of the plurality of subsystems related to the application program, and realizes the reduction of maintenance cost of the developer to maintain and develop the related SQL script of the application program, thereby achieving the effect of improving the working efficiency of the developer.
Optionally, in the application SQL script processing apparatus provided in the embodiment of the present application, the second obtaining unit 802 includes: the second judging subunit is used for judging whether a target SQL script exists according to the configuration file, wherein the target SQL script refers to an upgrade SQL script with version information of the upgrade SQL script in a second file position higher than that of the latest version information in the configuration file; the third obtaining subunit is configured to execute the target SQL script for the application program if the target SQL script exists in the second file location, and obtain version information of the upgraded SQL script according to the latest version information of the target SQL script; and the execution subunit is used for executing the target SQL script on the application program according to the configuration file and the development version information if the target SQL script does not exist in the second file position.
In this embodiment, in order for a developer to conveniently maintain or develop SQL scripts of a plurality of subsystems related to an application, after initializing a database corresponding to the application, it is necessary to continue the upgrade processing of the database: firstly, judging whether a target SQL script exists in a second file position by using a second judging subunit, wherein the version information of the target SQL script is higher than the latest version information recorded in the configuration file; if the target SQL script exists, determining that the current version of the database corresponding to the application program is not the latest version required by the developer, continuing to execute the target SQL script on the database, and acquiring version information of the upgrading SQL script by using a third acquisition subunit; if the target SQL script does not exist, determining that the current version of the database corresponding to the application program is the latest version developed by a developer, and continuing to process the application program through the execution subunit according to the configuration file and the development version information.
By reading the configuration file, judging whether the target SQL script exists in the second file position, and carrying out different treatments on the application program according to the judging result, the effects of separating the initialization SQL script of the application program and upgrading the SQL script are realized, the SQL script can be flexibly executed on the application program according to the actual condition of the application program, and the effect of improving the efficiency of maintaining and developing the related SQL script of the application program by a developer is further achieved.
Optionally, in the application SQL script processing apparatus provided in the embodiment of the present application, the execution subunit further includes: the first judging module is used for judging whether the development version information is empty or not if the target SQL script does not exist in the second file position; the execution module is used for continuing to execute the upgrade SQL script corresponding to the highest version in the configuration file for the application program if the development version information is not null; and the second judging module is used for not executing the SQL script on the application program if the development version information is empty.
In the development stage, a plurality of developers may modify the database corresponding to the application program together, and in this embodiment, in order to support that after the plurality of developers modify the SQL script in the development stage, the modified SQL script can be repeatedly executed when the program is started each time, so as to ensure that the plurality of developers can repeatedly test or modify the code corresponding to the application program in the development stage, whether the application program is in the development stage needs to be determined by using the first determination module according to the configured development version information. If the development version information is not null, confirming that the application program is in a development stage, and continuing to use the execution module to execute the upgrade SQL script corresponding to the highest version in the configuration file of the application program; if the development version information is empty, the second judging module confirms that the application program is not in the development stage, namely, the upgrading SQL script corresponding to the highest version in the configuration file is executed, so that the SQL script is not executed on the application program any more.
By setting the development mode for the application program, the method and the device can adaptively control whether the SQL script is repeatedly executed by the application program or not when the application program is started according to the specific development state of the developer, so that the effect of improving the working efficiency of the developer is achieved.
Optionally, in the application SQL script processing apparatus provided in the embodiment of the present application, the apparatus further includes: the fourth obtaining unit is used for obtaining the updated configuration file according to the version information of the updated SQL script, and obtaining the updated SQL script at the second file position if the application program is detected to release the new version; and the updating unit is used for updating the updated SQL script of the new version into the initialized SQL script of the corresponding subsystem of the first file position and setting the development version information to be null.
In order to facilitate the management of multiple subsystems and multiple versions of upgrade SQL scripts by a developer, after an application program issues a new version, the upgrade SQL scripts newly added by the multiple subsystems of the new version are acquired through a fourth acquisition unit at a second file position; and then adding the newly added upgrading SQL script of the plurality of subsystems in the new version into the initializing SQL script corresponding to the plurality of subsystems in the first file position through the updating unit, and setting the development version information to be null.
The new upgrading SQL scripts of the plurality of subsystems of the new version of the application program are added to the initializing SQL scripts corresponding to the plurality of subsystems in the first file position, so that developers can manage the upgrading SQL scripts corresponding to the plurality of subsystems and the upgrading SQL scripts corresponding to the plurality of versions more clearly and intuitively.
The application SQL script processing device includes a processor and a memory, where the first acquiring unit 801, the second acquiring unit 802, the third acquiring unit 803, the executing unit 804 and the like are stored as program units, and the processor executes the program units stored in the memory to implement corresponding functions.
The processor includes a kernel, and the kernel fetches the corresponding program unit from the memory. The kernel can be provided with one or more than one kernel, and the problem that a developer is difficult to maintain the upgrading SQL script related to the application program in the related technology is solved by adjusting the kernel parameters.
The memory may include volatile memory, random Access Memory (RAM), and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM), among other forms in computer readable media, the memory including at least one memory chip.
The embodiment of the invention provides a computer readable storage medium, wherein a program is stored on the computer readable storage medium, and the program is executed by a processor to realize the SQL script processing method of the application program.
The embodiment of the invention provides a processor which is used for running a program, wherein the application SQL script processing method is executed when the program runs.
The embodiment of the invention provides an electronic device, which comprises a processor, a memory and a program stored on the memory and capable of running on the processor, wherein the processor realizes the following steps when executing the program: after the application program is started, executing an initializing SQL script to the application program to obtain a configuration file of the application program, wherein the configuration file is used for recording version information of the upgrading SQL script executed when the application program is started each time; executing the upgrading SQL script on the application program according to the configuration file, and acquiring version information of the upgrading SQL script; according to the version information of the upgrade SQL script, obtaining an updated configuration file; and when the next starting of the application program is detected, executing the upgrading SQL script corresponding to the application program according to the updated configuration file.
The processor also realizes the following steps when executing the program: after the application program is started, executing an initializing SQL script on the application program, and acquiring the configuration file of the application program comprises the following steps: judging whether a configuration file exists or not; if the configuration file does not exist, executing an initializing SQL script on at least one subsystem of the application program to obtain the configuration file; if the configuration file exists, the existing configuration file is obtained.
The processor also realizes the following steps when executing the program: after the application program is started, executing an initializing SQL script on the application program, and before acquiring the configuration file of the application program, the method further comprises the following steps: configuring a first file position and a second file position of the application program, wherein the first file position is used for storing an initialization SQL script of at least one subsystem of the application program, and the second file position is used for storing an upgrade SQL script of the application program; the method comprises the steps of configuring current version information and development version information of an application program, wherein the current version information comprises application version information of the application program which is released and online, and the development version information is development version information of the application program in a development code stage.
The processor also realizes the following steps when executing the program: if the configuration file does not exist, executing an initializing SQL script on at least one subsystem of the application program to obtain the configuration file, wherein the step of obtaining the configuration file comprises the following steps: searching an initializing SQL script of at least one subsystem in a first file position through a class loader; executing an initializing SQL script in a first file position, and acquiring current version information of the initializing SQL script; and acquiring a configuration file according to the current version information.
The processor also realizes the following steps when executing the program: executing the upgrade SQL script on the application program according to the configuration file, and acquiring version information of the upgrade SQL script comprises: judging whether a target SQL script exists or not according to the configuration file, wherein the target SQL script refers to an upgrade SQL script with version information of the upgrade SQL script in a second file position higher than that of the latest version information in the configuration file; if the target SQL script exists in the second file position, executing the target SQL script by the application program, and obtaining version information of the upgraded SQL script according to the latest version information of the target SQL script; and if the target SQL script does not exist in the second file position, executing the target SQL script on the application program according to the configuration file and the development version information.
The processor also realizes the following steps when executing the program: if the target SQL script does not exist in the second file position, executing the target SQL script on the application program according to the configuration file and the development version information comprises: if the target SQL script does not exist in the second file position, judging whether the development version information is empty or not; if the development version information is not null, continuing to execute the upgrade SQL script corresponding to the highest version in the configuration file for the application program; if the development version information is null, the SQL script is not executed on the application.
The processor also realizes the following steps when executing the program: after obtaining the updated configuration file according to the version information of the upgrade SQL script, the method further comprises the following steps: if the application program is detected to release the new version, acquiring an upgrade SQL script of the new version at a second file position; updating the new version of upgrade SQL script into the initialization SQL script of the corresponding subsystem of the first file position, and setting the development version information to be null.
The device herein may be a server, PC, PAD, cell phone, etc.
The present application also provides a computer program product adapted to perform, when executed on a data processing device, a program initialized with the method steps of: after the application program is started, executing an initializing SQL script to the application program to obtain a configuration file of the application program, wherein the configuration file is used for recording version information of the upgrading SQL script executed when the application program is started each time; executing the upgrading SQL script on the application program according to the configuration file, and acquiring version information of the upgrading SQL script; according to the version information of the upgrade SQL script, obtaining an updated configuration file; and when the next starting of the application program is detected, executing the upgrading SQL script corresponding to the application program according to the updated configuration file.
When executed on a data processing device, is further adapted to carry out a program initialized with the method steps of: after the application program is started, executing an initializing SQL script on the application program, and acquiring the configuration file of the application program comprises the following steps: judging whether a configuration file exists or not; if the configuration file does not exist, executing an initializing SQL script on at least one subsystem of the application program to obtain the configuration file; if the configuration file exists, the existing configuration file is obtained.
When executed on a data processing device, is further adapted to carry out a program initialized with the method steps of: after the application program is started, executing an initializing SQL script on the application program, and before acquiring the configuration file of the application program, the method further comprises the following steps: configuring a first file position and a second file position of the application program, wherein the first file position is used for storing an initialization SQL script of at least one subsystem of the application program, and the second file position is used for storing an upgrade SQL script of the application program; the method comprises the steps of configuring current version information and development version information of an application program, wherein the current version information comprises application version information of the application program which is released and online, and the development version information is development version information of the application program in a development code stage.
When executed on a data processing device, is further adapted to carry out a program initialized with the method steps of: if the configuration file does not exist, executing an initializing SQL script on at least one subsystem of the application program to obtain the configuration file, wherein the step of obtaining the configuration file comprises the following steps: searching an initializing SQL script of at least one subsystem in a first file position through a class loader; executing an initializing SQL script in a first file position, and acquiring current version information of the initializing SQL script; and acquiring a configuration file according to the current version information.
When executed on a data processing device, is further adapted to carry out a program initialized with the method steps of: executing the upgrade SQL script on the application program according to the configuration file, and acquiring version information of the upgrade SQL script comprises: judging whether a target SQL script exists or not according to the configuration file, wherein the target SQL script refers to an upgrade SQL script with version information of the upgrade SQL script in a second file position higher than that of the latest version information in the configuration file; if the target SQL script exists in the second file position, executing the target SQL script by the application program, and obtaining version information of the upgraded SQL script according to the latest version information of the target SQL script; and if the target SQL script does not exist in the second file position, executing the target SQL script on the application program according to the configuration file and the development version information.
When executed on a data processing device, is further adapted to carry out a program initialized with the method steps of: if the target SQL script does not exist in the second file position, executing the target SQL script on the application program according to the configuration file and the development version information comprises: if the target SQL script does not exist in the second file position, judging whether the development version information is empty or not; if the development version information is not null, continuing to execute the upgrade SQL script corresponding to the highest version in the configuration file for the application program; if the development version information is null, the SQL script is not executed on the application.
When executed on a data processing device, is further adapted to carry out a program initialized with the method steps of: after obtaining the updated configuration file according to the version information of the upgrade SQL script, the method further comprises the following steps: if the application program is detected to release the new version, acquiring an upgrade SQL script of the new version at a second file position; updating the new version of upgrade SQL script into the initialization SQL script of the corresponding subsystem of the first file position, and setting the development version information to be null.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, etc., such as Read Only Memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises an element.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The foregoing is merely exemplary of the present application and is not intended to limit the present application. Various modifications and changes may be made to the present application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. which are within the spirit and principles of the present application are intended to be included within the scope of the claims of the present application.

Claims (10)

1. An application SQL script processing method is characterized by comprising the following steps:
after an application program is started, executing an initializing SQL script on the application program to obtain a configuration file of the application program, wherein the configuration file is used for recording version information of an upgrading SQL script executed when the application program is started each time;
executing the upgrading SQL script on the application program according to the configuration file, and acquiring version information of the upgrading SQL script;
obtaining an updated configuration file according to the version information of the upgrade SQL script;
and when the next starting of the application program is detected, executing the upgrading SQL script corresponding to the application program according to the updated configuration file.
2. The method of claim 1, wherein executing an initializing SQL script on an application after the application is started, the obtaining a configuration file for the application comprising:
judging whether the configuration file exists or not;
if the configuration file does not exist, executing the initializing SQL script on at least one subsystem of the application program to obtain the configuration file;
and if the configuration file exists, acquiring the existing configuration file.
3. The method of claim 2, wherein after an application is started, executing an initializing SQL script on the application, and before obtaining a configuration file of the application, the method further comprises:
configuring a first file position and a second file position of the application program, wherein the first file position is used for storing the initialization SQL script of at least one subsystem of the application program, and the second file position is used for storing the upgrading SQL script of the application program;
and configuring current version information and development version information of the application program, wherein the current version information comprises the application version information of the application program which is released and online, and the development version information is development version information of the application program in a development code stage.
4. The method of claim 3, wherein executing the initializing SQL script on at least one subsystem of the application program if the configuration file does not exist, the obtaining the configuration file comprising:
searching the initializing SQL script of at least one subsystem at the first file position through a class loader;
Executing the initializing SQL script at the first file position, and acquiring the current version information of the initializing SQL script;
and acquiring the configuration file according to the current version information.
5. The method of claim 4, wherein executing the upgrade SQL script on the application program according to the configuration file, and obtaining version information of the upgrade SQL script comprises:
judging whether a target SQL script exists or not according to the configuration file, wherein the target SQL script refers to the upgrading SQL script with version information of the upgrading SQL script in the second file position higher than that of the latest version information in the configuration file;
if the target SQL script exists in the second file position, executing the target SQL script on the application program, and obtaining version information of the upgrading SQL script according to the latest version information of the target SQL script;
and if the target SQL script does not exist in the second file position, executing the target SQL script on the application program according to the configuration file and the development version information.
6. The method of claim 5, wherein executing the target SQL script on the application program according to the configuration file and the development version information if the target SQL script does not exist in the second file location comprises:
If the target SQL script does not exist in the second file position, judging whether the development version information is empty or not;
if the development version information is not null, continuing to execute the upgrading SQL script corresponding to the highest version in the configuration file for the application program;
and if the development version information is empty, the SQL script is not executed on the application program.
7. A method according to claim 3, wherein after obtaining the updated configuration file according to the version information of the upgrade SQL script, the method further comprises:
if the application program is detected to release a new version, acquiring the upgrading SQL script of the new version at the second file position;
updating the new version of upgrade SQL script into the initialization SQL script of the corresponding subsystem of the first file position, and setting the development version information to be null.
8. An application SQL script processing apparatus, comprising:
the first acquisition unit is used for executing an initializing SQL script on the application program after the application program is started to acquire a configuration file of the application program, wherein the configuration file is used for recording version information of the upgrading SQL script executed when the application program is started each time;
The second obtaining unit is used for executing the upgrading SQL script on the application program according to the configuration file and obtaining version information of the upgrading SQL script;
the third acquisition unit is used for obtaining an updated configuration file according to the version information of the upgrade SQL script;
and the execution unit is used for executing the upgrading SQL script corresponding to the application program according to the updated configuration file when the next starting of the application program is detected.
9. A processor, wherein the processor is configured to run a program, and wherein the program runs to execute the method for processing the SQL script of the application according to any one of claims 1 to 7.
10. An electronic device comprising one or more processors and a memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the application SQL script processing method of any one of claims 1 to 7.
CN202310063821.9A 2023-01-12 2023-01-12 Application SQL script processing method and device, processor and electronic equipment Pending CN116049207A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310063821.9A CN116049207A (en) 2023-01-12 2023-01-12 Application SQL script processing method and device, processor and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310063821.9A CN116049207A (en) 2023-01-12 2023-01-12 Application SQL script processing method and device, processor and electronic equipment

Publications (1)

Publication Number Publication Date
CN116049207A true CN116049207A (en) 2023-05-02

Family

ID=86127131

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310063821.9A Pending CN116049207A (en) 2023-01-12 2023-01-12 Application SQL script processing method and device, processor and electronic equipment

Country Status (1)

Country Link
CN (1) CN116049207A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116610345A (en) * 2023-07-21 2023-08-18 上海柯林布瑞信息技术有限公司 Application program upgrading method and device based on execution record table
CN117348916A (en) * 2023-12-06 2024-01-05 中邮消费金融有限公司 Script generation method, device, equipment and storage medium

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116610345A (en) * 2023-07-21 2023-08-18 上海柯林布瑞信息技术有限公司 Application program upgrading method and device based on execution record table
CN116610345B (en) * 2023-07-21 2023-10-20 上海柯林布瑞信息技术有限公司 Application program upgrading method and device based on execution record table
CN117348916A (en) * 2023-12-06 2024-01-05 中邮消费金融有限公司 Script generation method, device, equipment and storage medium
CN117348916B (en) * 2023-12-06 2024-03-26 中邮消费金融有限公司 Script generation method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN106227579B (en) Docker container construction method and Docker management console
US10732963B2 (en) System and method for automatically managing updated UEFI variables
CN116049207A (en) Application SQL script processing method and device, processor and electronic equipment
CN110716845B (en) Log information reading method of Android system
CN107220074B (en) Method and device for accessing and upgrading supporting layer software function
US9542173B2 (en) Dependency handling for software extensions
US20160062754A1 (en) Coordinating Application Deployment with a Platform Tier
US20150149756A1 (en) System and method for setting up a bootable storage device using image
CN113238819B (en) Dynamic loading method and system of drive file suitable for U-Boot
CN112596762A (en) Rolling upgrading method and device
CN116991381B (en) Application cross compiling method and device, computing equipment and storage medium
US10540172B2 (en) System, method, and apparatus for zero downtime operating system transformation
CN117707543A (en) Application installation package manufacturing and installation method, computing device and storage medium
US10552135B1 (en) Reducing a size of an application package
CN117290059A (en) Cross-chip architecture linux virtual machine transfer method and system
CN116225617A (en) Management migration method and device for container instance, electronic equipment and storage medium
CN116382713A (en) Method, system, device and storage medium for constructing application mirror image
CN113467893B (en) Automatic testing method and device for virtual machine, storage medium and processor
CN115827028A (en) System upgrading method and device, storage medium and electronic equipment
US11720348B2 (en) Computing node allocation based on build process specifications in continuous integration environments
US20240256255A1 (en) Downgrading database software
CN112597131B (en) Distributed script control method and related device
CN113867776B (en) Method and device for issuing middle-stage application, electronic equipment and storage medium
CN107632934B (en) Function copying method and device in C-sharp
CN116719796A (en) Method and device for determining upgrading result, processor and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination