CN112130891A - Method and equipment for continuously deploying database - Google Patents

Method and equipment for continuously deploying database Download PDF

Info

Publication number
CN112130891A
CN112130891A CN202011006517.3A CN202011006517A CN112130891A CN 112130891 A CN112130891 A CN 112130891A CN 202011006517 A CN202011006517 A CN 202011006517A CN 112130891 A CN112130891 A CN 112130891A
Authority
CN
China
Prior art keywords
database
script
script file
specified
deployment
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.)
Granted
Application number
CN202011006517.3A
Other languages
Chinese (zh)
Other versions
CN112130891B (en
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.)
Shanghai Yixun Information Technology Co ltd
Original Assignee
Shanghai Yixun Information Technology 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 Shanghai Yixun Information Technology Co ltd filed Critical Shanghai Yixun Information Technology Co ltd
Priority to CN202011006517.3A priority Critical patent/CN112130891B/en
Publication of CN112130891A publication Critical patent/CN112130891A/en
Application granted granted Critical
Publication of CN112130891B publication Critical patent/CN112130891B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates

Landscapes

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

Abstract

The invention discloses a method and equipment for continuously deploying a database, wherein the method comprises the following steps: acquiring a specified database script from a preset version library according to database deployment requirements, wherein the deployment requirements comprise newly added deployment and upgraded deployment, the specified database script carries a specified version number that is consistent with the version number of the corresponding software code, constructing a corresponding specified script file in a physical target database according to the specified database script, and if the database deployment requirement is the upgrade deployment, generating a change database script according to the specified script file and a current script file, wherein the current script file is a script file corresponding to the database script of the current software version in the target database, and constructing a change script file in the target database according to the change database script, and changing the current script file based on the change script file, thereby improving the efficiency of continuous deployment of the database.

Description

Method and equipment for continuously deploying database
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for continuous deployment of a database.
Background
With the development of computers and software, particularly the development of the internet, the mobile internet and the big data industry, software systems become more and more complex, the number of hierarchical structures and modules becomes more and more, the software development period is long, and the software development, integration, testing and deployment become more and more important; agile software development approaches are becoming more and more widespread. Automated tools for the software development cycle to improve continuous integration and delivery efficiency and speed are becoming critical. Through the CI (Continuous Integration)/CD (Continuous Delivery/Continuous Deployment) tool, the development team can keep the software updated and put it into practice quickly.
At present, relatively mature methods and systems are available for continuous integration, continuous delivery and continuous deployment at the code level; continuous integration, continuous delivery, and continuous deployment and container technologies make application packaging and deployment faster and easier. Data is the most important part of an application, and since all applications contain Data, database migration, database continuous delivery and database continuous deployment are much more complex than application packaging and deployment, and deployment and basic Data deployment of DDL (Data Definition Language) are involved, and how to upgrade and deploy a database is a huge challenge and a troublesome problem especially on the basis of existing stock Data, and the database is not a file collection, is a container of the most valuable assets, and contains business Data which must be reserved. The database deployment includes scripts that handle database Schema structures (table structures), database code (procedures, functions, etc.), and data used by the application (metadata, lookup content, or parameter tables). Development teams need approaches to reliably control, migrate, and test real application data.
Automation is achieved by submitting database object change scripts to a traditional version control library, which is of very limited use, lacks flexibility and is disassociated with the database itself. It may also be unrealistic, easily resulting in lost updates to the target environment due to change conflicts. For automation, there is a risk of using a "compare and synchronize" tool. These two concepts are not compatible because they do not know each other.
For some teams, the application data is moved through CI/CD pipeline, and in order to maintain compliance and be compatible with other problems, the application data is always manually moved, and the application data cannot be effectively expanded. Are generally suitable for only a small number of applications and cannot migrate between different environments.
Therefore, how to improve the efficiency and reliability of the continuous deployment of the database, and to realize the automation of the continuous delivery and the continuous deployment of the database, so as to improve the efficiency and the automation rate of the continuous integration, the continuous delivery and the continuous deployment of the software system is a technical problem to be solved at present.
Disclosure of Invention
The invention discloses a method for continuously deploying a database, which is used for solving the technical problems that the efficiency and the reliability of the continuous deployment of the database are low and the continuous deployment of the database cannot be automatically carried out in the prior art, and comprises the following steps:
acquiring a specified database script from a preset version library according to database deployment requirements, wherein the deployment requirements comprise newly added deployment and upgraded deployment, and the specified database script is provided with a specified version number consistent with the version number of a corresponding software code;
constructing a corresponding appointed script file in a physical target database according to the appointed database script;
if the database deployment requirement is the upgrading deployment, generating a change database script according to the specified script file and a current script file, wherein the current script file is a script file corresponding to a database script of a current software version in the target database;
and constructing a change script file in the target database according to the change database script, and changing the current script file based on the change script file.
In some embodiments, generating a change database script according to the specified script file and the current script file specifically includes:
determining a first result based on object list comparison of the specified script file and the current script file;
determining a second result based on object comparison of the specified script file and the current script file;
determining a third result based on data comparison of the specified script file and the current script file;
and generating the change database script according to the first result, the second result and the third result.
In some embodiments, before obtaining the specified database script with the specified version number from the preset version library according to the database deployment requirement, the method further includes:
configuring a release strategy according to metadata of a software development database, wherein the release strategy comprises a release strategy of a database object and a release strategy of data;
generating a data definition language and a data manipulation language of a database according to the release strategy;
exporting the data definition language and the data manipulation language generates an export database script,
and generating the specified database script based on adding the specified version number in the exported database script, and storing the specified database script to the preset version library.
In some embodiments, the determining a first result based on comparing the object list of the specified script file and the current script file specifically includes:
determining a first object set according to a first object list to be compared in the appointed script file;
determining a second object set according to a second object list to be compared corresponding to the first object list to be compared in the current script file;
determining the first result according to the comparison result of the first object set and the second object set, wherein,
if the first object set has a newly added object relative to the second object set, translating an issuing script of the newly added object into the change database script;
if the first object set has a deleted object relative to the second object set, no processing is performed;
and if the first object set has consistent objects relative to the second object set, performing object comparison on the consistent objects.
In some embodiments, the determining a second result based on object comparison between the specified script file and the current script file specifically includes:
determining a first object attribute set according to a first object to be compared of the specified script file;
determining a second object attribute set according to a second object to be compared corresponding to the first object to be compared in the current script file;
determining the second result according to the comparison result of the first object attribute set and the second object attribute set, wherein,
if the first object attribute set has a newly added attribute relative to the second object attribute set, generating a first alert statement based on the newly added attribute;
if the first object attribute set has a deleted attribute relative to the second object attribute set, generating a second alert statement based on the deleted attribute;
and if the first object attribute set has consistent attributes relative to the second object attribute set, not processing.
In some embodiments, the determining a third result based on data comparison between the specified script file and the current script file specifically includes:
determining a first main key set according to a first database table to be compared of the specified script file;
determining a second main key set according to a second database table to be compared, corresponding to the first database table to be compared, in the current script file;
determining the third result according to the comparison result of the first primary key set and the second primary key set, wherein,
if the first primary key set has newly added data relative to the second primary key set, generating a data insertion script based on the newly added data;
if the first primary key set has deleted data relative to the second primary key set, generating a data deletion script based on the deleted data;
and if the first main key set has consistent data relative to the second main key set, generating a data upgrading script based on the consistent data.
In some embodiments, after building a corresponding specified script file in a physical target database according to the specified database script, the method further comprises:
and if the database deployment requirement is the newly added deployment, taking the specified script file as the database script file corresponding to the specified version number.
In some embodiments, the configurations are organized in Schema units.
Correspondingly, the invention also discloses a device for continuously deploying the database, which comprises:
the system comprises an acquisition module, a database deployment module and a database deployment module, wherein the acquisition module is used for acquiring a specified database script from a preset version library according to database deployment requirements, the deployment requirements comprise newly added deployment and upgraded deployment, and the specified database script is provided with a specified version number consistent with the version number of a corresponding software code;
the construction module is used for constructing a corresponding specified script file in a physical target database according to the specified database script;
a generating module, configured to generate a change database script according to the specified script file and a current script file if the database deployment requirement is the upgrade deployment, where the current script file is a script file corresponding to a database script of a current software version in the target database;
and the change module is used for constructing a change script file in the target database according to the change database script and changing the current script file based on the change script file.
The invention also discloses a computer readable storage medium, wherein the computer readable storage medium stores instructions, and when the instructions are run on the terminal equipment, the instructions cause the terminal equipment to execute the method for continuously deploying the database.
Compared with the prior art, the invention has the following beneficial effects:
the invention discloses a method and equipment for continuously deploying a database, wherein the method comprises the following steps: acquiring a specified database script from a preset version library according to database deployment requirements, wherein the deployment requirements comprise newly added deployment and upgraded deployment, the specified database script is provided with a specified version number consistent with the version number of a corresponding software code, a corresponding specified script file is constructed in a physical target database according to the specified database script, if the database deployment requirements are the upgraded deployment, a changed database script is generated according to the specified script file and a current script file, the current script file is a script file in the target database corresponding to a database script of a current software version, a changed script file is constructed in the target database according to the changed database script, and the current script file is changed based on the changed script file, so that the efficiency and the reliability of the continuous deployment of the database are improved, the automation of continuous delivery and continuous deployment of the database is realized, and the efficiency and the automation degree of continuous integration, continuous delivery and continuous deployment of the software system are further improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a flowchart illustrating a method for continuous deployment of a database according to an embodiment of the present application;
FIG. 2 is a flow chart illustrating a method for continuous deployment of a database according to another embodiment of the present application;
FIG. 3 is a diagram illustrating relationships between a set of database objects and database objects in an embodiment of the present application;
FIG. 4 is a diagram illustrating a relationship between sets of database objects in version N and version M in an embodiment of the present application;
FIG. 5 is a diagram showing a database table in version N in the embodiment of the present application;
FIG. 6 shows a diagram of the same database table in version M corresponding to version N in the embodiment of the present application;
FIG. 7 is a diagram showing the comparison result of the same database table in version N and version M in the embodiment of the present application;
FIG. 8 is a diagram showing data in a database table in version N in the embodiment of the present application;
fig. 9 is a schematic structural diagram of an apparatus for continuous deployment of a database according to an embodiment of the present application;
FIG. 10 is a diagram showing data in the same database table corresponding to version N in version M in the embodiment of the present application;
fig. 11 shows a schematic diagram of the comparison result of the same data in version N and version M in the embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
As described in the background, as computers and software develop, software systems become more complex, hierarchies and modules become more and more, software development cycle is long, and software development, integration, testing and deployment become more and more important.
Continuous integration: the method is characterized in that after a new code is submitted, the new code is immediately constructed and tested, whether the new code and an original code can be correctly integrated or not can be determined in the testing process, if a problem occurs in the testing process, information which is returned is also returned to a development department, continuous integration is a practice of a software development cycle, a code warehouse, a construction tool and a testing tool are integrated together, the code is frequently combined into a backbone and then automatically constructed and tested, simple continuous integration is a tool for monitoring code change in a version control system, and when the code change occurs, automatic compilation and testing can be performed and subsequent custom-defined actions can be performed.
And (3) continuous delivery: the method is characterized in that the integrated codes are deployed in a more close and real production environment on the basis of continuous integration, data support can be improved in the close and real production environment, further testing can be carried out, and if the further testing is not problematic, the integrated codes can be deployed in the production environment on line.
Continuous deployment: the method is characterized in that the process of deployment in a production environment is automated on the basis of continuous delivery, manual participation is not needed in the deployment, and if problems occur in the deployment process, codes are immediately rolled back.
In the prior art, continuous integration, continuous delivery and continuous deployment are only targeted software code parts, and continuous integration, continuous delivery and continuous deployment of a database are not targeted, so that the continuous deployment and upgrading deployment of the database are complex, manual, time-consuming and labor-consuming, the efficiency and reliability of the continuous deployment of the database are low, and the continuous deployment of the database cannot be performed automatically.
In order to solve the above technical problem, in an embodiment of the present application, a method for continuously deploying a database is provided, as shown in fig. 1, the method includes:
step S101, acquiring a specified database script from a preset version library according to database deployment requirements, wherein the deployment requirements comprise newly added deployment and upgraded deployment, and the specified database script is provided with a specified version number consistent with the version number of a corresponding software code.
Specifically, when the existing database has a deployment requirement, a specified database script is obtained from a preset version library according to the deployment requirement, the existing database deployment requirement comprises newly added deployment and upgraded deployment, and the specified database script has a specified version number consistent with the version number of the corresponding software code, so that the versions are unified and standardization is realized.
In order to more accurately deploy the database, in a preferred embodiment of the present application, before acquiring a specified database script with a specified version number from a preset version library according to a database deployment requirement, the method further includes:
configuring a release strategy according to metadata of a software development database, wherein the release strategy comprises a release strategy of a database object and a release strategy of data;
generating a data definition language and a data manipulation language of a database according to the release strategy;
exporting the data definition language and the data manipulation language generates an export database script,
and generating the specified database script based on adding the specified version number in the exported database script, and storing the specified database script to the preset version library.
Specifically, the publishing strategy can be configured according to metadata of a software development database, the publishing strategy includes a publishing strategy of a data object and a publishing strategy of data, the publishing strategy of the database object includes publishing strategies of a table, a view, a sequence, an index and the like, the publishing strategy of the data includes a publishing strategy of basic configuration data, the publishing strategy of the database is whether the database object is published, some temporarily tested databases may not need to be published, and the publishing strategy of the data includes whether the data is synchronized, source full or partial synchronization, and target library total replacement or merging replacement.
Generating a Data Definition Language (DDL) and a Data Manipulation Language (DML) of the database according to the release strategy, then exporting the Data Definition Language and the Data Manipulation Language, thereby generating an export database script, and meanwhile, adding a specified version number in the export database script to generate a specified database script, so as to facilitate the subsequent deployment operation of the formulated version and the comparison operation of different versions, and storing the specified database script in a preset version library.
In order to better perform the configuration publishing policy, in a preferred embodiment of the present application, the configuration is organized in units of Schema (collection of database objects).
It should be noted that, the manner of generating the specified database script according to the publishing policy of the database object and the data in the above preferred embodiment is only a specific implementation manner in the present application, and other manners of generating the deployable specified database script according to the database object and the data all belong to the scope of protection of the present application.
And S102, constructing a corresponding specified script file in a physical target database according to the specified database script.
In this step, in order to perform new deployment and/or upgrade deployment on the database, a corresponding formulated script file needs to be constructed in a physical target database according to a specified database script, so as to generate a database object and data.
In order to better deploy the database, in a preferred embodiment of the present application, after constructing a corresponding specified script file in a physical target database according to the specified database script, the method further includes:
and if the database deployment requirement is the newly added deployment, taking the specified script file as the database script file corresponding to the specified version number.
Specifically, if the deployment requirement is new deployment, the specified script file constructed in the physical target database is directly used as the database script file corresponding to the specified version number, so that the database is newly added and deployed.
It should be noted that the scheme for constructing the formulated script file in the above preferred embodiment is only a specific implementation manner in the present application, and other manners for constructing the corresponding specified script file in the physical target database according to the formulated database script all belong to the protection scope of the present application.
Step S103, if the database deployment requirement is the upgrade deployment, generating a change database script according to the specified script file and a current script file, wherein the current script file is a script file corresponding to a database script of a current software version in the target database.
Specifically, if the database deployment requirement is upgrade deployment, a change database script needs to be generated according to a specified script file and a current script file, where the current script file is a corresponding script file of a database script of a current software version in a physical target database.
It should be noted that, the requirement for upgrading and deploying the database is that objects or data in the database of the current software version are added, modified or deleted to upgrade the database, and the same or different data and objects exist in the current script file and the specified script file, so that a changed database script needs to be generated according to the specified script file and the current script file to complete accurate upgrading and deploying of the data.
In order to generate the change database script more accurately, in a preferred embodiment of the present application, the generating the change database script according to the specified script file and the current script file specifically includes:
determining a first result based on object list comparison of the specified script file and the current script file;
determining a second result based on object comparison of the specified script file and the current script file;
determining a third result based on data comparison of the specified script file and the current script file;
and generating the change database script according to the first result, the second result and the third result.
Specifically, the change database script may be generated by comparing the designated script file with the current script file, and the comparison between the designated script file and the current script file is divided into three comparisons, that is: the method comprises the following steps of object list comparison, object comparison and data comparison, then determining a first result according to the object list comparison, determining a second result according to the object comparison, determining a third result according to the data comparison, and finally generating a change database script according to the first result, the second result and the third result.
In order to determine the first result more accurately, in a preferred embodiment of the present application, the determining the first result is based on comparing the object list of the specified script file and the current script file, and specifically includes:
determining a first object set according to a first object list to be compared in the appointed script file;
determining a second object set according to a second object list to be compared corresponding to the first object list to be compared in the current script file;
determining the first result according to the comparison result of the first object set and the second object set, wherein,
if the first object set has a newly added object relative to the second object set, translating an issuing script of the newly added object into the change database script;
if the first object set has a deleted object relative to the second object set, no processing is performed;
and if the first object set has consistent objects relative to the second object set, performing object comparison on the consistent objects.
Specifically, the specified script file and the current script file are compared with each other in an object list, newly added objects and intersection objects (an intersection and a complementary set are found out by applying a set theory) are found out, different sets are subjected to different processing strategies, the intersection part is compared, the newly added part is directly subjected to script translation, and the cleaned or deleted part is not processed in principle, so that the safety and stability of data are ensured.
The method comprises the steps of firstly determining a first object set according to a first object list to be compared in a designated script file, then determining a second object set according to a second object list to be compared corresponding to the first object list to be compared in a current script file, then comparing the first object set with the second object set, and determining a first result according to a comparison result.
And if the first object set has a deleted object relative to the second object set, performing no processing, and if the first object set has a consistent object relative to the second object set, performing object comparison on the consistent object.
In order to determine the second result more accurately, in a preferred embodiment of the present application, the determining the second result is based on performing object comparison on the specified script file and the current script file, and specifically includes:
determining a first object attribute set according to a first object to be compared of the specified script file;
determining a second object attribute set according to a second object to be compared corresponding to the first object to be compared in the current script file;
determining the second result according to the comparison result of the first object attribute set and the second object attribute set, wherein,
if the first object attribute set has a newly added attribute relative to the second object attribute set, generating a first alert statement based on the newly added attribute;
if the first object attribute set has a deleted attribute relative to the second object attribute set, generating a second alert statement based on the deleted attribute;
and if the first object attribute set has consistent attributes relative to the second object attribute set, not processing.
Specifically, the object comparison is to perform comparison operation according to the object Definition condition, if there is no difference between the two, the DDL (Data Definition Language) statements are not synchronous, if there is a difference between the two, a corresponding alert (scripting Language) statement is generated, and after the object comparison, corresponding Data comparison work is performed according to the configuration condition.
The method comprises the steps of firstly determining a first object attribute set according to a first object to be compared of a designated script file, then determining a second object attribute set according to a second object to be compared corresponding to the first object to be compared in the current script file, and then determining a second result according to the comparison result of the first object attribute set and the second object attribute set.
If the first object attribute set has a newly added attribute relative to the second object attribute set, generating a first alert statement based on the newly added attribute, if the first object attribute set has a deleted attribute relative to the second attribute object set, generating a second alert statement based on the deleted attribute, and if the first object attribute set has a consistent attribute relative to the second object attribute set, not processing.
In order to determine the third result more accurately, in this embodiment of the application, the determining the third result based on data comparison between the specified script file and the current script file specifically includes:
determining a first main key set according to a first database table to be compared of the specified script file;
determining a second main key set according to a second database table to be compared, corresponding to the first database table to be compared, in the current script file;
determining the third result according to the comparison result of the first primary key set and the second primary key set, wherein,
if the first primary key set has newly added data relative to the second primary key set, generating a data insertion script based on the newly added data;
if the first primary key set has deleted data relative to the second primary key set, generating a data deletion script based on the deleted data;
and if the first main key set has consistent data relative to the second main key set, generating a data upgrading script based on the consistent data.
Specifically, the data comparison first determines a first primary key set according to a first database table to be compared in the designated script file, then determines a second primary key set according to a second database table to be compared corresponding to the first database table to be compared in the current script file, and then determines a third result according to a comparison result of the first primary key set and the second primary key set.
If the first main key set has the added data relative to the second main key set, generating a data insertion script based on the added data, if the first main key set has the deleted data relative to the second main key set, claiming a data deletion script based on the deleted data, and if the first main key set has the consistent data relative to the second main key set, generating a data upgrading script based on the consistent data.
It should be noted that, the manner of determining the first result, the second result, the third result, and determining the changed database script in the above preferred embodiment is only a specific implementation manner of the present application, and a person skilled in the art may determine the first result, the second result, and the third result according to the application of practical situations flexibly, or determine the changed database script of the current script file relative to the specified script file, so as to implement the deployment requirement of the database, which does not affect the protection scope of the present application.
And step S104, constructing a change script file in the target database according to the change database script, and changing the current script file based on the change script file.
In the step, a change script file is constructed in a physical target database according to the determined change database script, and the current script file is changed based on the change script file so as to realize the requirement of upgrading and deploying the database.
By applying the technical scheme, the appointed database script is obtained from the preset version library according to the database deployment requirement, the deployment requirement comprises newly added deployment and upgraded deployment, the appointed database script is provided with an appointed version number consistent with the version number of the corresponding software code, a corresponding appointed script file is built in a physical target database according to the appointed database script, if the database deployment requirement is the upgraded deployment, a changed database script is generated according to the appointed script file and a current script file, the current script file is a script file corresponding to the database script of the current software version in the target database, a changed script file is built in the target database according to the changed database script, the current script file is changed based on the changed script file, and the standardization, the continuous delivery and the continuous deployment of the database are realized, Standardization and automation greatly improve the efficiency and reliability of continuous deployment of the database.
In order to further explain the technical idea of the present application, the technical solution of the present application is now described with reference to specific application scenarios.
Another embodiment of the present application provides a method for continuous deployment of a database, which configures metadata of a software development database, selects an appointed database script of an appointed version from a preset version library according to a deployment requirement according to a configuration release policy, and determines an upgrade script, that is, changes the database script, by comparing an appointed script file corresponding to the appointed database script with a current script, thereby completing the deployment requirement of the database according to the upgrade script, realizing standardization, standardization and automation of continuous delivery and continuous deployment of the database, and greatly improving the efficiency of continuous deployment of the database.
As shown in fig. 2, the method comprises the following specific steps:
and step S201, configuration is carried out.
The method comprises the steps of configuring a publishing strategy based on metadata of a software development database, wherein the configured publishing strategy comprises a publishing strategy of a database object and a publishing strategy of data, the publishing strategy of the database object comprises publishing strategies of tables, views, sequences, indexes and the like, the publishing strategy of the data comprises a basic publishing strategy of configuration data, the publishing strategy of the database is whether the database object is published or not, some temporarily tested databases may not need to be published, configuring a database object list consistent with the version number of corresponding software codes, and the publishing strategy of the data comprises whether data are synchronized, source full or partial synchronization, and target database total replacement or merging replacement.
In the configuration process, the Schema is organized in units of Schema, where the Schema is a set of database objects associated with each other, and a relationship between the Schema and the database objects may be as shown in fig. 3, where the database objects are tables, indexes, views, storage processes, and the like.
And step S202, issuing according to the issuing strategy.
Specifically, a data definition language and a data manipulation language of the database are generated according to the configuration release strategy, then a exported database script is generated according to the data definition language and the data manipulation language, a specified version number consistent with a corresponding software code version number is added in the exported database script, so that a specified database script is generated, and the specified database script is stored in a preset version library.
And step S203, deploying according to the specified database script.
In this step, a corresponding specified script file is constructed in the physical target database according to the specified database script, and a target database object and data are generated.
The method further includes the steps of judging whether the deployment requirement of the database is upgrading deployment or newly added deployment, if the deployment requirement is newly added deployment, directly using a specified script file constructed in a physical target database as a database script file corresponding to a specified version number so as to enable the database to complete the newly added deployment, and if the deployment requirement is upgrading deployment, continuing to execute the step S204.
And step S204, comparing the specified script file with the current script file.
Specifically, the comparison operation is to perform comparison operation on two versions of script files to generate a change database script, and the comparison consists of three parts: object list comparison, object comparison and data comparison.
Object list alignment: the method comprises the steps of comparing object lists in an appointed script file and an existing script file, finding out newly added objects and intersection objects (an intersection and a complementary set are found out by applying a set theory), carrying out different subsequent processing on different sets, carrying out object comparison on intersection parts one by one, directly carrying out script translation on the newly added parts, and carrying out no processing on deleted or cleaned parts in principle so as to ensure data safety and stability.
As shown in fig. 4, version N is an object set in the specified script file, and version M is an object set in the current script file, which can determine that:
the newly added objects of version N relative to version M are as follows:
Figure BDA0002696138340000131
directly translating the issued script of the object of the newly added part into a change database script;
the objects of version N pruned relative to version M are:
Figure BDA0002696138340000132
the deletion part is not processed;
the object of version N matching version M is a ≠ B ═ B ∈ a, and B ∈ B }, and the matching part needs to be subjected to object matching operation.
And (3) object alignment: the object comparison is to perform comparison operation according to the object definition condition, if the two are not different, the DDL statements are not synchronous, if the two are different, a corresponding alert statement is generated, and after the object comparison, corresponding data comparison operation is performed according to the configuration condition.
If the attribute set of an object in version N is defined as C and the attribute set of the same object in version M is defined as D, then:
the newly added attributes are:
Figure BDA0002696138340000141
performing attribute alert table add processing;
the pruned attributes are:
Figure BDA0002696138340000142
performing attribute alert table delete processing;
and the attribute of the version N, which is consistent with the version M, is C and D, wherein g belongs to C and g belongs to D, and processing is not carried out.
The database table in version N is shown in FIG. 5, the corresponding same database table in version M is shown in FIG. 6, and the comparison result between the same database table in version N and version M is shown in FIG. 7.
And (3) data comparison: if the primary key set of a certain table in version N is defined as E and the primary key set of the same table in version M is defined as F, then:
the newly added data of the version N table corresponding to the same table in the version M is as follows:
Figure BDA0002696138340000143
converting into lnsert intro operation;
the data deleted by the version N table corresponding to the same table in the version M is:
Figure BDA0002696138340000144
converting into delete operation;
the version N table contains the data consistent with the same table in the English version M: e ≠ F ═ k ∈ E, and k ∈ F }, which translates into update operation.
The data in the database table of version N is shown in fig. 8, the data in the same corresponding database table of version M is shown in fig. 10, and the comparison result between the data in the same database table of version N and version M is shown in fig. 11.
And generating a change database script according to the three comparison results.
And S205, upgrading and deploying.
Specifically, a change script file is built in a physical target database according to a change database script, and then the current script file is changed based on the change script file, so that the requirement of upgrading and deploying the database is met.
By applying the technical scheme, the metadata of the database is developed through software to be configured, then the appointed database script of the appointed version is selected from the preset version library according to the deployment requirement according to the configuration release strategy, the upgrading script is determined through the comparison between the appointed script file corresponding to the appointed database script and the current script, namely the database script is changed, so that the deployment requirement of the database is met according to the upgrading script, the standardization, standardization and automation of the continuous delivery and continuous deployment of the database are realized, and the efficiency of the continuous deployment of the database is greatly improved.
Corresponding to the method for continuously deploying the database in the embodiment of the present application, an embodiment of the present application further provides a device for continuously deploying the database, as shown in fig. 9, including:
an obtaining module 901, configured to obtain a specified database script from a preset version library according to a database deployment requirement, where the deployment requirement includes a new deployment and an upgraded deployment, and the specified database script has a specified version number that is consistent with a version number of a corresponding software code;
a constructing module 902, configured to construct a corresponding specified script file in a physical target database according to the specified database script;
a generating module 903, configured to generate a change database script according to the specified script file and a current script file if the database deployment requirement is the upgrade deployment, where the current script file is a script file corresponding to a database script of a current software version in the target database;
and the changing module 904 is configured to construct a change script file in the target database according to the change database script, and change the current script file based on the change script file.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit the same; although the present application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not necessarily depart from the spirit and scope of the corresponding technical solutions in the embodiments of the present application.

Claims (10)

1. A method for continuous deployment of a database, the method comprising:
acquiring a specified database script from a preset version library according to database deployment requirements, wherein the deployment requirements comprise newly added deployment and upgraded deployment, and the specified database script is provided with a specified version number consistent with the version number of a corresponding software code;
constructing a corresponding appointed script file in a physical target database according to the appointed database script;
if the database deployment requirement is the upgrading deployment, generating a change database script according to the specified script file and a current script file, wherein the current script file is a script file corresponding to a database script of a current software version in the target database;
and constructing a change script file in the target database according to the change database script, and changing the current script file based on the change script file.
2. The method of claim 1, wherein generating a change database script based on the specified script file and the current script file comprises:
determining a first result based on object list comparison of the specified script file and the current script file;
determining a second result based on object comparison of the specified script file and the current script file;
determining a third result based on data comparison of the specified script file and the current script file;
and generating the change database script according to the first result, the second result and the third result.
3. The method of claim 1, wherein prior to obtaining the specified database script with the specified version number from the pre-provisioned version library according to the database deployment requirements, the method further comprises:
configuring a release strategy according to metadata of a software development database, wherein the release strategy comprises a release strategy of a database object and a release strategy of data;
generating a data definition language and a data manipulation language of a database according to the release strategy;
exporting the data definition language and the data manipulation language generates an export database script,
and generating the specified database script based on adding the specified version number in the exported database script, and storing the specified database script to the preset version library.
4. The method of claim 2, wherein determining a first result based on comparing the object list of the specified script file and the current script file comprises:
determining a first object set according to a first object list to be compared in the appointed script file;
determining a second object set according to a second object list to be compared corresponding to the first object list to be compared in the current script file;
determining the first result according to the comparison result of the first object set and the second object set, wherein,
if the first object set has a newly added object relative to the second object set, translating an issuing script of the newly added object into the change database script;
if the first object set has a deleted object relative to the second object set, no processing is performed;
and if the first object set has consistent objects relative to the second object set, performing object comparison on the consistent objects.
5. The method of claim 2, wherein determining a second result based on object comparison of the specified script file and the current script file comprises:
determining a first object attribute set according to a first object to be compared of the specified script file;
determining a second object attribute set according to a second object to be compared corresponding to the first object to be compared in the current script file;
determining the second result according to the comparison result of the first object attribute set and the second object attribute set, wherein,
if the first object attribute set has a newly added attribute relative to the second object attribute set, generating a first alert statement based on the newly added attribute;
if the first object attribute set has a deleted attribute relative to the second object attribute set, generating a second alert statement based on the deleted attribute;
and if the first object attribute set has consistent attributes relative to the second object attribute set, not processing.
6. The method of claim 2, wherein determining a third result based on comparing the specified script file and the current script file comprises:
determining a first main key set according to a first database table to be compared of the specified script file;
determining a second main key set according to a second database table to be compared, corresponding to the first database table to be compared, in the current script file;
determining the third result according to the comparison result of the first primary key set and the second primary key set, wherein,
if the first primary key set has newly added data relative to the second primary key set, generating a data insertion script based on the newly added data;
if the first primary key set has deleted data relative to the second primary key set, generating a data deletion script based on the deleted data;
and if the first main key set has consistent data relative to the second main key set, generating a data upgrading script based on the consistent data.
7. The method of claim 1, wherein after building a corresponding specified script file in a physical target database according to the specified database script, the method further comprises:
and if the database deployment requirement is the newly added deployment, taking the specified script file as the database script file corresponding to the specified version number.
8. The method of claim 3, wherein the configurations are organized in units of schemas.
9. An apparatus for continuous deployment of a database, the apparatus comprising:
the system comprises an acquisition module, a database deployment module and a database deployment module, wherein the acquisition module is used for acquiring a specified database script from a preset version library according to database deployment requirements, the deployment requirements comprise newly added deployment and upgraded deployment, and the specified database script is provided with a specified version number consistent with the version number of a corresponding software code;
the construction module is used for constructing a corresponding specified script file in a physical target database according to the specified database script;
a generating module, configured to generate a change database script according to the specified script file and a current script file if the database deployment requirement is the upgrade deployment, where the current script file is a script file corresponding to a database script of a current software version in the target database;
and the change module is used for constructing a change script file in the target database according to the change database script and changing the current script file based on the change script file.
10. A computer-readable storage medium having stored therein instructions that, when executed on a terminal device, cause the terminal device to perform the method of database persistence deployment as claimed in any one of claims 1 to 8.
CN202011006517.3A 2020-09-23 2020-09-23 Method and equipment for continuously deploying database Active CN112130891B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011006517.3A CN112130891B (en) 2020-09-23 2020-09-23 Method and equipment for continuously deploying database

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011006517.3A CN112130891B (en) 2020-09-23 2020-09-23 Method and equipment for continuously deploying database

Publications (2)

Publication Number Publication Date
CN112130891A true CN112130891A (en) 2020-12-25
CN112130891B CN112130891B (en) 2021-06-29

Family

ID=73842678

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011006517.3A Active CN112130891B (en) 2020-09-23 2020-09-23 Method and equipment for continuously deploying database

Country Status (1)

Country Link
CN (1) CN112130891B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112783863A (en) * 2021-01-26 2021-05-11 中国人寿保险股份有限公司上海数据中心 Standard delivery method, system, device and medium for multi-type database
CN113535218A (en) * 2021-07-26 2021-10-22 平安信托有限责任公司 System database script publishing method, device, equipment and storage medium
CN113792026A (en) * 2021-08-11 2021-12-14 深圳力维智联技术有限公司 Deployment method and device of database script and computer readable storage medium
CN117131004A (en) * 2023-07-05 2023-11-28 海通证券股份有限公司 Database changing method and device and electronic equipment

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030158733A1 (en) * 2001-03-13 2003-08-21 Toshiya Nonaka Character type speak system
CN102402559A (en) * 2010-09-16 2012-04-04 中兴通讯股份有限公司 Database upgrade script generating method and device
CN103577907A (en) * 2012-07-24 2014-02-12 阿里巴巴集团控股有限公司 Continuous integration testing method and system
CN105553733A (en) * 2015-12-23 2016-05-04 北京安托软件技术有限公司 Resource monitoring and management system
CN106250178A (en) * 2016-07-26 2016-12-21 北京北森云计算股份有限公司 The method that system dynamics function intercepts extension online is realized by the compiling of multilingual cloud
CN109376139A (en) * 2018-08-15 2019-02-22 中国平安人寿保险股份有限公司 Centralized database monitoring method, computer installation and storage medium
CN110633284A (en) * 2019-09-19 2019-12-31 中国工商银行股份有限公司 Method and device for changing table in database
US20200089596A1 (en) * 2017-04-16 2020-03-19 International Business Machines Corporation Integrating Synthetic Performance Measurements with Continuous Delivery Pipelines
CN111142899A (en) * 2019-12-12 2020-05-12 东软集团股份有限公司 Database script execution method and device, storage medium and electronic equipment
CN111158708A (en) * 2019-12-25 2020-05-15 上海精鲲计算机科技有限公司 Task arrangement engine system

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030158733A1 (en) * 2001-03-13 2003-08-21 Toshiya Nonaka Character type speak system
CN102402559A (en) * 2010-09-16 2012-04-04 中兴通讯股份有限公司 Database upgrade script generating method and device
CN103577907A (en) * 2012-07-24 2014-02-12 阿里巴巴集团控股有限公司 Continuous integration testing method and system
CN105553733A (en) * 2015-12-23 2016-05-04 北京安托软件技术有限公司 Resource monitoring and management system
CN106250178A (en) * 2016-07-26 2016-12-21 北京北森云计算股份有限公司 The method that system dynamics function intercepts extension online is realized by the compiling of multilingual cloud
US20200089596A1 (en) * 2017-04-16 2020-03-19 International Business Machines Corporation Integrating Synthetic Performance Measurements with Continuous Delivery Pipelines
CN109376139A (en) * 2018-08-15 2019-02-22 中国平安人寿保险股份有限公司 Centralized database monitoring method, computer installation and storage medium
CN110633284A (en) * 2019-09-19 2019-12-31 中国工商银行股份有限公司 Method and device for changing table in database
CN111142899A (en) * 2019-12-12 2020-05-12 东软集团股份有限公司 Database script execution method and device, storage medium and electronic equipment
CN111158708A (en) * 2019-12-25 2020-05-15 上海精鲲计算机科技有限公司 Task arrangement engine system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
JASON: "Fear database changes? Get them under control with CI/CD", 《HTTPS://HACKERNOON.COM/DATABASE-CHANGES-CAN-BE-SCARY-HOW-R1HY2GFE》 *
周文洋: ""DevOps流水线之数据库篇"", 《HTTPS://DEVOPSHUB.CN/2018/08/25/DATABASE-DEVOPS-WITH-TFS/》 *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112783863A (en) * 2021-01-26 2021-05-11 中国人寿保险股份有限公司上海数据中心 Standard delivery method, system, device and medium for multi-type database
CN113535218A (en) * 2021-07-26 2021-10-22 平安信托有限责任公司 System database script publishing method, device, equipment and storage medium
CN113792026A (en) * 2021-08-11 2021-12-14 深圳力维智联技术有限公司 Deployment method and device of database script and computer readable storage medium
CN113792026B (en) * 2021-08-11 2023-08-11 深圳力维智联技术有限公司 Method and device for deploying database script and computer-readable storage medium
CN117131004A (en) * 2023-07-05 2023-11-28 海通证券股份有限公司 Database changing method and device and electronic equipment

Also Published As

Publication number Publication date
CN112130891B (en) 2021-06-29

Similar Documents

Publication Publication Date Title
CN112130891B (en) Method and equipment for continuously deploying database
US8615768B2 (en) Dependency-ordered resource synchronization across multiple environments using change list created based on dependency-ordered graphs of the multiple environments
US20140297592A1 (en) Computer-readable medium storing program and version control method
CN104965735A (en) Apparatus for generating upgrade SQL script
CN104423960A (en) Continuous project integration method and continuous project integration system
CN103514223A (en) Data synchronism method and system of database
CN105302533A (en) Code synchronizing method and apparatus
US8677376B2 (en) Expressing equivalency relationships with identity graphs across multiple environments to create change list to be traversed to conform the environments
CN109508355A (en) A kind of data pick-up method, system and terminal device
CN107025108B (en) Exporting hierarchical data from a Source Code Management (SCM) system to a Product Lifecycle Management (PLM) system
CN110543469B (en) Database version management method and server
CN109871470B (en) Power grid equipment data labeling management system and implementation method
US20230012642A1 (en) Method and device for snapshotting metadata, and storage medium
CN115712623B (en) Batch data fault-tolerant collection method based on captured metadata change
CN109376153A (en) System and method for writing data into graph database based on NiFi
CN111932207A (en) Project data processing method and device, computer equipment and storage medium
CN106951593B (en) Method and device for generating configuration file of protection measurement and control device
CN108959391B (en) Apparatus, system, method, and storage medium for presenting database cluster architecture diagram
CN108491218A (en) A kind of method and apparatus of databases comparison file generated
US20220129418A1 (en) Method for determining blood relationship of data, electronic device and storage medium
CN115454971A (en) Data migration method and device, electronic equipment and storage medium
CN114116664B (en) Database table-building sentence processing method, device, computer equipment and storage medium
CN113868138A (en) Method, system, equipment and storage medium for acquiring test data
CN114625751A (en) Data tracing query method and device based on block chain
CN105069174A (en) Configurable A+B mode record navigation method

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
GR01 Patent grant
GR01 Patent grant