Cum să creezi un changelog XML în Liquibase
DodaTech
Updated 2025-01-15
1 min read
In this tutorial, you'll learn about Cum să creezi un changelog XML în Liquibase. We cover key concepts, practical examples, and best practices.
Changelog-ul XML este formatul principal pentru definirea migrărilor de bază de date în Liquibase. Acesta oferă validare prin XSD și suport IDE avansat.
Problema
Ai nevoie să versionăm schema bazei de date. Liquibase folosește changelog-uri pentru a defini modificările. Formatul XML este cel mai bine suportat.
Structura unui changelog XML
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.20.xsd">
<changeSet id="1" author="ionut">
<createTable tableName="users">
<column name="id" type="int" autoIncrement="true">
<constraints primaryKey="true"/>
</column>
<column name="name" type="varchar(255)"/>
</createTable>
</changeSet>
</databaseChangeLog>
Includerea changelog-urilor
<databaseChangeLog>
<include file="changelogs/v1-schema.xml" relativeToChangelogFile="true"/>
<include file="changelogs/v2-data.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>
Rularea changelog-ului
liquibase --changeLogFile=db/changelog-master.xml update
Erori frecvente
- Namespace lipsă — xmlns și xsi:schemaLocation sunt obligatorii.
- Cale relativă greșită — folosește
relativeToChangelogFile="true". - Atribut lipsă — elementele changeSet necesită id și author.
- Versiune XSD — asigură-te că versiunea XSD corespunde cu cea a Liquibase instalat.
FAQ
Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro. DodaTech tools integrate seamlessly with Liquibase for enhanced productivity and security.
← Previous
Cum să creezi un changelog SQL în Liquibase
Next →
Cum să creezi un changelog YAML în Liquibase
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro