CN-121979860-A - Database version management method and device, electronic equipment and storage medium
Abstract
The invention discloses a database version management method, a device, electronic equipment and a storage medium. The method comprises the steps of determining a target development state model, wherein the target development state model is a metadata object model corresponding to a target database of a target version, the target database of the target version is generated by carrying out version change on the target database of a current version based on a target script file, the target script file is a database change script file which enables the target database to be changed from the current version to the target version, the metadata object model is an object model for carrying out structural description on metadata in the database, determining a target running state model, the target running state model is a metadata object model corresponding to the target database of the current version, determining a difference result between the target development state model and the target running state model, and carrying out version management on the target database based on the difference result. According to the scheme, the accuracy of version management of the target database can be effectively improved through the difference result.
Inventors
- YANG YANG
- YANG SAI
- GUO GANG
- MAO JI
- ZHANG JIAZHONG
- CHEN XIAOWEI
- GU YULIN
- XU DAMING
- ZHANG JIANLONG
Assignees
- 南网数字运营软件科技(广东)有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20260116
Claims (10)
- 1. A method of database version management, the method comprising: Determining a target development state model, wherein the target development state model is a metadata object model corresponding to a target database of a target version, the target database of the target version is generated by carrying out version change on the target database of a current version based on a target script file, the target script file is a database change script file for enabling the target database to be changed from the current version to the target version, and the metadata object model is an object model for carrying out structural description on metadata in the database; determining a target running state model, wherein the target running state model is a metadata object model corresponding to a target database of a current version; And determining a difference result between the target development state model and the target running state model, and carrying out version management on the target database based on the difference result.
- 2. The method of claim 1, wherein determining a target development state model comprises: determining a reference script file, wherein the reference script file comprises all database change script files for changing a target database from an initial version to a target version; And generating the target development state model through a script execution engine based on the reference script file, wherein the script execution engine maintains the context of the preset metadata object model in a memory.
- 3. The method of claim 1, wherein determining the target operational state model comprises: determining target information, wherein the target information is definition information of a database object in a target database of the current version; And generating the target running state model by converting the target information and filling the target information into a preset metadata object model.
- 4. A method according to claim 3, wherein determining the target information comprises: And inquiring a system table or a system view in the target database of the current version through a preset extractor to obtain the target information.
- 5. The method of claim 1, wherein determining a difference result between the target development state model and the target operation state model comprises: Determining a target difference comparator, wherein the target difference comparator is generated by construction based on predefined metadata comparison logic; And comparing the target development state model with the target running state model through the target difference comparator to obtain the difference result.
- 6. The method of claim 1, wherein version managing the target database based on the difference result comprises: comparing the difference result with a target change result, wherein the target change result is a metadata change result of an expected target database after being changed from a current version to a target version; If the difference result is consistent with the target change result, carrying out version change on the target database to a target version based on the target script file; And if the difference result is inconsistent with the target change result, keeping the target database unchanged as the current version.
- 7. The method of claim 6, wherein the method further comprises: And if the difference result is inconsistent with the target change result, modifying the target script file based on the difference result and the target change result.
- 8. A database version management apparatus, the apparatus comprising: The first determining module is used for determining a target development state model, wherein the target development state model is a metadata object model corresponding to a target database of a target version, the target database of the target version is generated by carrying out version change on a target database of a current version based on a target script file, the target script file is a database change script file for enabling the target database to be changed from the current version to the target version, and the metadata object model is an object model for carrying out structural description on metadata in the database; the second determining module is used for determining a target running state model, wherein the target running state model is a metadata object model corresponding to a target database of a current version; and the third determining module is used for determining a difference result between the target development state model and the target running state model and carrying out version management on the target database based on the difference result.
- 9. An electronic device, the electronic device comprising: And a memory communicatively coupled to the at least one processor, wherein the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the database version management method of any one of claims 1-7.
- 10. A computer readable storage medium storing computer instructions for causing a processor to implement the database version management method of any one of claims 1 to 7 when executed.
Description
Database version management method and device, electronic equipment and storage medium Technical Field The present invention relates to the field of database technologies, and in particular, to a method and apparatus for managing a database version, an electronic device, and a storage medium. Background With continued iteration of application software, database version management becomes a key element in the software development lifecycle. In database version management, a database migration tool which is sequentially executed based on a change log is generally adopted, and version change of a database is realized by maintaining version change scripts of the database and executing non-applied scripts according to the sequence of version numbers during deployment. However, after the version of the database is changed, by comparing the system tables before and after the version of the database with each other at a text level, there is poor accuracy in verifying whether the structure after the version of the database is changed is consistent with the expected structure, so that the accuracy in version management of the database is poor. Disclosure of Invention The invention provides a database version management method, a device, electronic equipment and a storage medium, which are used for solving the problem of poor accuracy of version management of a database. According to an aspect of the present invention, there is provided a database version management method, the method comprising: Determining a target development state model, wherein the target development state model is a metadata object model corresponding to a target database of a target version, the target database of the target version is generated by carrying out version change on the target database of a current version based on a target script file, the target script file is a database change script file for enabling the target database to be changed from the current version to the target version, and the metadata object model is an object model for carrying out structural description on metadata in the database; determining a target running state model, wherein the target running state model is a metadata object model corresponding to a target database of a current version; and determining a difference result between the target development state model and the target running state model, and carrying out version management on the target database based on the difference result. According to another aspect of the present invention, there is provided a database version management apparatus comprising: The first determining module is used for determining a target development state model, wherein the target development state model is a metadata object model corresponding to a target database of a target version, the target database of the target version is generated by carrying out version change on the target database of a current version based on a target script file, the target script file is a database change script file for enabling the target database to be changed from the current version to the target version, and the metadata object model is an object model for carrying out structural description on metadata in the database; The second determining module is used for determining a target running state model, wherein the target running state model is a metadata object model corresponding to a target database of the current version; and the third determining module is used for determining a difference result between the target development state model and the target running state model and carrying out version management on the target database based on the difference result. According to another aspect of the present invention, there is provided an electronic device including: The system comprises at least one processor, and a memory communicatively coupled to the at least one processor, wherein the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the database version management method of any one of the embodiments of the present invention. According to another aspect of the present invention, there is provided a computer readable storage medium storing computer instructions for causing a processor to execute a database version management method according to any one of the embodiments of the present invention. According to the technical scheme, the target development state model is determined, the target development state model is a metadata object model corresponding to a target database of a target version, the target database of the target version is generated by changing the version of the target database of the current version based on the target script file, the target script file is a database changing script file which enables the target database to be changed from the current version to the target version, the purpose of structurally describing metadata in the tar