{"id":447132,"date":"2025-02-05T15:03:06","date_gmt":"2025-02-05T15:03:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=447132"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=447132","title":{"rendered":"<span>\u041a\u0430\u043a GitLab \u0441 Liquibase \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0432 ClickHouse \u0432\u0435\u0437\u043b\u0438<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>Liquibase<\/strong>, <strong>GitLab<\/strong> \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e <strong>Python<\/strong> \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0439, \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u0438 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0434\u043b\u044f ClickHouse \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1f2\/ae3\/9af\/1f2ae39af4e63bd5813f174828105bb4.png\" width=\"1232\" height=\"928\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1f2\/ae3\/9af\/1f2ae39af4e63bd5813f174828105bb4.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f13\/2f6\/365\/f132f63650618e0e3c31f6148e9eba27.png\" width=\"1120\" height=\"72\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f13\/2f6\/365\/f132f63650618e0e3c31f6148e9eba27.png\"\/><\/figure>\n<ul>\n<li>\n<p>\u0414\u043b\u044f  Clickhouse  \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430  \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0438 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u043d\u0430 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f, \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0432 \u0440\u0443\u0447\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0411\u0414.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043a\u0430\u0442\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0432 \u043e\u0434\u0438\u043d \u043a\u043b\u0438\u043a.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0442\u0430: \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u043c SQL.<\/p>\n<\/li>\n<\/ul>\n<h2>Liquibase<\/h2>\n<p><strong>Liquibase<\/strong> \u2014 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0411\u0414. \u041d\u043e \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u043d\u044e\u0430\u043d\u0441 (\u043a\u0430\u043a \u0432\u0441\u0435\u0433\u0434\u0430) \u2013 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438 Liquibase \u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 ClickHouse \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u043c. \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0431\u044b\u043b \u043d\u0430\u0439\u0434\u0435\u043d \u043f\u043b\u0430\u0433\u0438\u043d <a href=\"https:\/\/github.com\/arenadata\/liquibase-clickhouse\/tree\/master\"><strong><u>Liquibase-ClickHouse<\/u><\/strong><\/a> \u043e\u0442 Arenadata. \u041f\u043b\u0430\u0433\u0438\u043d \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430, Liquibase \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435  \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043a\u0430\u043a <u>\u0440\u0435\u043f\u043b\u0438\u0446\u0438\u0440\u0443\u0435\u043c\u044b\u0435<\/u>, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <u>ON CLUSTER<\/u> \u0432 SQL \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u0445. <\/p>\n<p>\u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0435 \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u043b\u0430\u0433\u0438\u043d \u2013 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 shared \u0434\u043b\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 Liquibase. \u0415\u0441\u043b\u0438 \u0432\u0430\u0448 \u043a\u043b\u0430\u0441\u0442\u0435\u0440, \u043a\u0430\u043a \u0438 \u043d\u0430\u0448, \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 shared, \u0442\u043e \u0438\u043c\u0435\u0439\u0442\u0435 \u0432 \u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b Liquibase \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u043b\u0438\u0448\u044c \u043d\u0430 \u0442\u043e\u043c \u0448\u0430\u0440\u0434\u0435 \u0438 \u0435\u0433\u043e \u043d\u043e\u0434\u0430\u0445, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0431\u044b\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Liquibase.<\/p>\n<ol>\n<li>\n<p>Liquibase \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0444\u0430\u0439\u043b changelog.xml \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u043c\u0438. \u041a\u0430\u0436\u0434\u0430\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 <strong>changeSet<\/strong>.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043b\u0430\u0433\u0438\u043d Liquibase-ClickHouse Arenadata \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 SQL-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u043c, \u0430 \u043f\u0443\u0442\u044c \u0434\u043e SQL-\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c changelog.xml \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <strong>sqlFile path=&#187;path\/example_path&#187;<\/strong>. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0439 SQL \u0432\u043c\u0435\u0441\u0442\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430 Liquibase.<\/p>\n<\/li>\n<li>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 &lt;tagDatabase tag=&#187;1&#8243;&gt; \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u044e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0441\u043c\u043e\u0436\u0435\u043c \u0434\u043e \u043d\u0435\u0435 \u043e\u0442\u043a\u0430\u0442\u0438\u0442\u044c\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p> \u0427\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c <strong>rollback<\/strong>, \u043f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>sqlFile<\/strong> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 changeSet \u0431\u043b\u043e\u043a rollback, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u0443\u0442\u044c \u0434\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u0436\u0435 sql \u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u043d\u043e \u0443\u0436\u0435 \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043e\u0442\u043a\u0430\u0442\u0430.<\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440 changelog.xml \u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u043f\u0443\u043d\u043a\u0442\u044b.<\/p>\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt; &lt;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-3.8.xsd\"&gt;     &lt;changeSet id=\"1\" author=\"ivanov\"&gt;         &lt;tagDatabase tag=\"1\"\/&gt;     &lt;\/changeSet&gt;     &lt;changeSet id=\"2\" author=\"petrov\"&gt;         &lt;sqlFile path=\"migration\/1_create_first_table.sql\" relativeToChangelogFile=\"true\"\/&gt;         &lt;rollback&gt;             &lt;sqlFile path=\"rollback\/1_delete_first_table.sql\" relativeToChangelogFile=\"true\"\/&gt;         &lt;\/rollback&gt;     &lt;\/changeSet&gt;             &lt;changeSet id=\"3\" author=\"petrov\"&gt;         &lt;tagDatabase tag=\"2\"\/&gt;     &lt;\/changeSet&gt;         &lt;\/databaseChangeLog&gt;<\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<h3>GitLab CI\/CD: \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439<\/h3>\n<p>\u0412\u0435\u0441\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u043b\u043e\u0436\u0438\u0442\u0441\u044f \u043d\u0430 \u043f\u043b\u0435\u0447\u0438 \u0447\u0435\u0440\u0435\u0437 GitLab CI\/CD. \u041f\u043e\u043b\u043d\u044b\u0439 flow Pipeline \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043d\u0430 3\u0445 stage, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u0442\u0435\u043c\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<h4>Validate ChangeLog.xml<\/h4>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a changelog.xml \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438.<\/p>\n<p>\u0427\u0442\u043e \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u0443\u0435\u043c? \u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 changelog.xml, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u043f\u0440\u0438\u0432\u0435\u043b \u0432\u044b\u0448\u0435.<\/p>\n<ol>\n<li>\n<p> \u0423\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c changeSet ID<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/52b\/f9e\/5db\/52bf9e5dbe9eeb7fa4ef8422e19c7f6b.png\" width=\"1120\" height=\"602\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/52b\/f9e\/5db\/52bf9e5dbe9eeb7fa4ef8422e19c7f6b.png\"\/><\/figure>\n<\/li>\n<li>\n<p>\u0423\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0441\u0442\u044c (\u0432\u0441\u0435 \u0442\u0435\u0433\u0438 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u0431\u0435\u0437 sevmer \u0438 \u0442.\u0434.) \u0442\u0435\u0433\u043e\u0432 tagDatabase<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/287\/d95\/547\/287d95547eff4f26c26f74704482bb7d.png\" width=\"1120\" height=\"602\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/287\/d95\/547\/287d95547eff4f26c26f74704482bb7d.png\"\/><\/figure>\n<\/li>\n<li>\n<p> \u041d\u0430\u043b\u0438\u0447\u0438\u0435 \u0431\u043b\u043e\u043a\u0430 <code>&lt;rollback&gt;<\/code> \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e changeSet.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6f9\/7f2\/c9e\/6f97f2c9ef7e4b72594f5cab8f22d18b.png\" width=\"1120\" height=\"626\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6f9\/7f2\/c9e\/6f97f2c9ef7e4b72594f5cab8f22d18b.png\"\/><\/figure>\n<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0437\u0430 \u0432\u0441\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 CICD \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0443 \u043d\u0430\u0441 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 cli \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u043d\u0430 Python, \u0442\u043e \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e changelog.xml \u0431\u044b\u043b\u043e \u0434\u043e\u0432\u0435\u0440\u0435\u043d\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0435\u0439. \u0427\u0430\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u0430:<\/p>\n<details class=\"spoiler\">\n<summary>\u043a\u043e\u0434 \u0442\u0443\u0442\u044c<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import logging from enum import StrEnum from functools import cached_property  from lxml import etree   class ValidateUniqIdsError(Exception):     def __str__(self):         return (             \"\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 changeset ID \u043d\u0435 \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u0430! \"             \"\u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0447\u0442\u043e  \u0432\u0441\u0435 id changeset'\u043e\u0432 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438.\"         )   class ValidateChangesetIdsAscendingError(Exception):     def __str__(self):         return (             \"\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 ID changeset \u0431\u0434 \u043d\u0435 \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u0430! \"             \"\u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0447\u0442\u043e \u0432\u0441\u0435 ID \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044f.\"         )   class ValidateTagVersionsAscendingError(Exception):     def __str__(self):         return (             \"\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 tag version \u0441\u0445\u0435\u043c\u044b \u0411\u0414  \u043d\u0435 \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u0430! \u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0447\u0442\u043e \u0432\u0441\u0435 tag \"             \"version \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044f.\"         )   class ValidateUniqTagVersionsError(Exception):     def __str__(self):         return (             \"\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 tag version \u0441\u0445\u0435\u043c\u044b \u0411\u0414  \u043d\u0435 \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u0430. \u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0447\u0442\u043e \u0432\u0441\u0435 tag \"             \"version \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438.\"         )   class ValidateAreValuesIncrementingByOneError(Exception):     def __init__(self, tag_id: int):         self.tag_id = tag_id      def __str__(self):         return (             f\"TAG: {self.tag_id}  \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e TAG'\u0430 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u043d\u0430 1. \"             f\"\u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 rollback \u0434\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0411\u0414.\"         )   class ValidateExistenceRollbackInChangesetError(Exception):     def __init__(self, changeset_id: int):         self.changeset_id = changeset_id      def __str__(self):         return (             f\"\u0432 ChangeSet c ID: {self.changeset_id} \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c &lt;rollback&gt;&lt;\/rollback&gt; \"             f\"\u0431\u043b\u043e\u043a \u0441  SQL \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c \u043e\u0442\u043a\u0430\u0442\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.\"         )   class LiquiShit(StrEnum):     common = \"{http:\/\/www.liquibase.org\/xml\/ns\/dbchangelog}\"     rollback = f\"{common}rollback\"     sql_file = f\"{common}sqlFile\"     changeset = f\"{common}changeSet\"     tag_database = f\"{common}tagDatabase\"   class LiquibaseChangelogWorker:     def __init__(self, changelog_filename: str):         self.changelog_filename = changelog_filename      @cached_property     def xml_tree(self):         return etree.parse(self.changelog_filename).getroot()      @cached_property     def all_changesets(self):         return self.xml_tree.findall(LiquiShit.changeset)      @cached_property     def all_tags(self):         return [             int(changeset[0].get(\"tag\"))             for changeset in self.all_changesets             if changeset.findall(LiquiShit.tag_database)         ]      @cached_property     def all_sql_changesets(self):         return [             changeset             for changeset in self.all_changesets             if changeset.findall(LiquiShit.sql_file)         ]      @cached_property     def all_changeset_ids(self) -&gt; list:         return [             int(changeset.attrib.get(\"id\"))             for changeset in self.all_changesets         ]      def get_last_tag(self) -&gt; str:         return str(self.all_tags[-1])      def validate_uniq_ids(self) -&gt; None:          if len(self.all_changeset_ids) == len(set(self.all_changeset_ids)):             logging.info(\"\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f uniq changeset ID \u043f\u0440\u043e\u0448\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e!\")             return         raise ValidateUniqIdsError      def validate_changeset_ids_ascending(self):         if self.all_changeset_ids == sorted(self.all_changeset_ids):             logging.info(                 \"\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 ID changeset  \u043f\u0440\u043e\u0448\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e!\"             )             return         raise ValidateChangesetIdsAscendingError      def validate_tag_versions_ascending(self) -&gt; None:         if self.all_tags == sorted(self.all_tags):             logging.info(                 \"\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 tag version \u0441\u0445\u0435\u043c\u044b \u0411\u0414 \u043f\u0440\u043e\u0448\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e!\"             )             return         raise ValidateTagVersionsAscendingError      def validate_uniq_tag_versions(self) -&gt; None:         if len(self.all_tags) == len(set(self.all_tags)):             logging.info(                 \"\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 tag version \u0441\u0445\u0435\u043c\u044b \u0411\u0414 \u043f\u0440\u043e\u0448\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e!\"             )             return         raise ValidateUniqTagVersionsError      def validate_are_values_incrementing_by_one(self) -&gt; None:         for index, _tag in enumerate(self.all_tags[:-1]):             if self.all_tags[index] + 1 != self.all_tags[index + 1]:                 raise ValidateAreValuesIncrementingByOneError(                     self.all_tags[index + 1]                 )         logging.info(             \"\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u043d\u0430 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0435 \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u0435 tag version \u043f\u0440\u043e\u0448\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e!\"         )      def validate_existence_rollback_in_changeset(self) -&gt; None:         for sql_changeset in self.all_sql_changesets:             if not sql_changeset.findall(LiquiShit.rollback):                 raise ValidateExistenceRollbackInChangesetError(                     sql_changeset.attrib.get(\"id\")                 )         logging.info(             \"\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0432 ChangeSet \u0431\u043b\u043e\u043a\u0430 \u0441 rollback \u043f\u0440\u043e\u0448\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e!\"         ) <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h4>Deploy Dev, Stage, Prod. \u0412\u044b\u043a\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043d\u0430 \u043a\u043e\u043d\u0442\u0443\u0440 dev\/stg\/prod<\/h4>\n<pre><code class=\"yaml\">script:   - liquibase update --changelog-file=changelog-master.xml --username=$CLICKHOUSE_USER --password=$CLICKHOUSE_PASSWORD --url=jdbc:clickhouse:\/\/$CLICKHOUSE_HOST:$CLICKHOUSE_PORT\/$CLICKHOUSE_DB_NAME --driver=com.clickhouse.jdbc.ClickHouseDriver --defaultSchemaName=$CLICKHOUSE_DB_NAME  --logLevel=OFF<\/code><\/pre>\n<h4>Rollback Dev, Stage, Prod<\/h4>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c \u0431\u043b\u043e\u043a\u0430\u043c &lt;rollback&gt; , \u043d\u0430\u043b\u0438\u0447\u0438\u044e \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u043c\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c \u0432 SQL \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 \u043e\u0442\u043a\u0430\u0442\u0430, tagDatabase GitlabJob \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043a\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 (\u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u0438 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u043b\u0438\u0441\u044c tagDatabase). \u0422\u0430\u043a\u0436\u0435 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0436\u0435\u0441\u0442\u043a\u043e\u0439 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 changelog.xml \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0411\u0414 \u043d\u0430 1 \u043c\u0435\u043d\u044c\u0448\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0439, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u0435\u0442 \u043b\u043e\u0433\u0438\u043a\u0443 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 rollback<\/p>\n<pre><code class=\"yaml\">script:   - ROLLBACK_TO_VERSION=$((LAST_TAG_DB-1))   - liquibase rollback --tag=${ROLLBACK_TO_VERSION} --changelog-file=changelog-master.xml --username=$CLICKHOUSE_USER --password=$CLICKHOUSE_PASSWORD --url=jdbc:clickhouse:\/\/$CLICKHOUSE_HOST:$CLICKHOUSE_PORT\/$CLICKHOUSE_DB_NAME --driver=com.clickhouse.jdbc.ClickHouseDriver --defaultSchemaName=$CLICKHOUSE_DB_NAME  --logLevel=OFF<\/code><\/pre>\n<p><\/p>\n<p>P.S: \u043e\u0442\u043a\u0443\u0434\u0430 \u0431\u0435\u0440\u0435\u0442\u0441\u044f <strong>LAST_TAG_DB<\/strong> \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u0435 \u0412\u044b? \u0412 \u0431\u043b\u043e\u043a\u0435 \u043a\u043e\u0434\u0430 \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434 get_last_tag, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 tagDatabase. \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043c\u044b \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c build.env \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0430 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">def save_last_tag(self):   with open(\"build.env\", \"w\") as f:     f.write(         f\"LAST_TAG_DB={self.liquibase_changelog_validator.get_last_tag()}\\n\"             )<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/371\/0ad\/7a7\/3710ad7a77ac33483b30473fcd3c10d9.png\" width=\"1120\" height=\"72\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/371\/0ad\/7a7\/3710ad7a77ac33483b30473fcd3c10d9.png\"\/><\/figure>\n<ol>\n<li>\n<p>\u041f\u043e\u043b\u043d\u0430\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439, \u043e\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0434\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043d\u044b\u0445 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 ClickHouse \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f Liquibase + <a href=\"https:\/\/github.com\/arenadata\/liquibase-clickhouse\/tree\/master\">\u0434\u043e\u0431\u0440\u044b\u0435 \u043b\u044e\u0434\u0438<\/a>.<\/p>\n<\/li>\n<li>\n<p>\u041c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0448\u0438\u0431\u043e\u043a \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c: \u043a\u0430\u0436\u0434\u044b\u0439 changeSet \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d, \u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0411\u0414 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u0430\u0442\u0438\u0442\u044c \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043a\u0438 \u0432 Gitlab Pipeline<\/p>\n<\/li>\n<\/ol>\n<p>\u041c\u044b \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b\u0438 \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 ClickHouse \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430. \u0425\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0443\u0441\u043b\u044b\u0448\u0430\u0442\u044c, \u043a\u0430\u043a \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u0445 \u0440\u0435\u0448\u0430\u044e\u0442 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u0434\u0435\u043b\u0438\u0442\u0435\u0441\u044c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445!<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/879280\/\"> https:\/\/habr.com\/ru\/articles\/879280\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>Liquibase<\/strong>, <strong>GitLab<\/strong> \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e <strong>Python<\/strong> \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0439, \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u0438 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0434\u043b\u044f ClickHouse \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430.<\/p>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<ul>\n<li>\n<p>\u0414\u043b\u044f  Clickhouse  \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430  \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0438 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u043d\u0430 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f, \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0432 \u0440\u0443\u0447\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0411\u0414.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043a\u0430\u0442\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0432 \u043e\u0434\u0438\u043d \u043a\u043b\u0438\u043a.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0442\u0430: \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u043c SQL.<\/p>\n<\/li>\n<\/ul>\n<h2>Liquibase<\/h2>\n<p><strong>Liquibase<\/strong> \u2014 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0411\u0414. \u041d\u043e \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u043d\u044e\u0430\u043d\u0441 (\u043a\u0430\u043a \u0432\u0441\u0435\u0433\u0434\u0430) \u2013 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438 Liquibase \u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 ClickHouse \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u043c. \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0431\u044b\u043b \u043d\u0430\u0439\u0434\u0435\u043d \u043f\u043b\u0430\u0433\u0438\u043d <a href=\"https:\/\/github.com\/arenadata\/liquibase-clickhouse\/tree\/master\"><strong><u>Liquibase-ClickHouse<\/u><\/strong><\/a> \u043e\u0442 Arenadata. \u041f\u043b\u0430\u0433\u0438\u043d \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430, Liquibase \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435  \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043a\u0430\u043a <u>\u0440\u0435\u043f\u043b\u0438\u0446\u0438\u0440\u0443\u0435\u043c\u044b\u0435<\/u>, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <u>ON CLUSTER<\/u> \u0432 SQL \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u0445. <\/p>\n<p>\u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0435 \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u043b\u0430\u0433\u0438\u043d \u2013 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 shared \u0434\u043b\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 Liquibase. \u0415\u0441\u043b\u0438 \u0432\u0430\u0448 \u043a\u043b\u0430\u0441\u0442\u0435\u0440, \u043a\u0430\u043a \u0438 \u043d\u0430\u0448, \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 shared, \u0442\u043e \u0438\u043c\u0435\u0439\u0442\u0435 \u0432 \u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b Liquibase \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u043b\u0438\u0448\u044c \u043d\u0430 \u0442\u043e\u043c \u0448\u0430\u0440\u0434\u0435 \u0438 \u0435\u0433\u043e \u043d\u043e\u0434\u0430\u0445, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0431\u044b\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Liquibase.<\/p>\n<ol>\n<li>\n<p>Liquibase \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0444\u0430\u0439\u043b changelog.xml \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u043c\u0438. \u041a\u0430\u0436\u0434\u0430\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 <strong>changeSet<\/strong>.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043b\u0430\u0433\u0438\u043d Liquibase-ClickHouse Arenadata \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 SQL-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u043c, \u0430 \u043f\u0443\u0442\u044c \u0434\u043e SQL-\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c changelog.xml \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <strong>sqlFile path=&#187;path\/example_path&#187;<\/strong>. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0439 SQL \u0432\u043c\u0435\u0441\u0442\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430 Liquibase.<\/p>\n<\/li>\n<li>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 &lt;tagDatabase tag=&#187;1&#8243;&gt; \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u044e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0441\u043c\u043e\u0436\u0435\u043c \u0434\u043e \u043d\u0435\u0435 \u043e\u0442\u043a\u0430\u0442\u0438\u0442\u044c\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p> \u0427\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c <strong>rollback<\/strong>, \u043f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>sqlFile<\/strong> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 changeSet \u0431\u043b\u043e\u043a rollback, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u0443\u0442\u044c \u0434\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u0436\u0435 sql \u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u043d\u043e \u0443\u0436\u0435 \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043e\u0442\u043a\u0430\u0442\u0430.<\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440 changelog.xml \u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u043f\u0443\u043d\u043a\u0442\u044b.<\/p>\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt; &lt;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-3.8.xsd\"&gt;     &lt;changeSet id=\"1\" author=\"ivanov\"&gt;         &lt;tagDatabase tag=\"1\"\/&gt;     &lt;\/changeSet&gt;     &lt;changeSet id=\"2\" author=\"petrov\"&gt;         &lt;sqlFile path=\"migration\/1_create_first_table.sql\" relativeToChangelogFile=\"true\"\/&gt;         &lt;rollback&gt;             &lt;sqlFile path=\"rollback\/1_delete_first_table.sql\" relativeToChangelogFile=\"true\"\/&gt;         &lt;\/rollback&gt;     &lt;\/changeSet&gt;             &lt;changeSet id=\"3\" author=\"petrov\"&gt;         &lt;tagDatabase tag=\"2\"\/&gt;     &lt;\/changeSet&gt;         &lt;\/databaseChangeLog&gt;<\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<h3>GitLab CI\/CD: \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439<\/h3>\n<p>\u0412\u0435\u0441\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u043b\u043e\u0436\u0438\u0442\u0441\u044f \u043d\u0430 \u043f\u043b\u0435\u0447\u0438 \u0447\u0435\u0440\u0435\u0437 GitLab CI\/CD. \u041f\u043e\u043b\u043d\u044b\u0439 flow Pipeline \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043d\u0430 3\u0445 stage, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u0442\u0435\u043c\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<h4>Validate ChangeLog.xml<\/h4>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a changelog.xml \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438.<\/p>\n<p>\u0427\u0442\u043e \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u0443\u0435\u043c? \u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 changelog.xml, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u043f\u0440\u0438\u0432\u0435\u043b \u0432\u044b\u0448\u0435.<\/p>\n<ol>\n<li>\n<p> \u0423\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c changeSet ID<\/p>\n<figure class=\"full-width\"><\/figure>\n<\/li>\n<li>\n<p>\u0423\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0441\u0442\u044c (\u0432\u0441\u0435 \u0442\u0435\u0433\u0438 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u0431\u0435\u0437 sevmer \u0438 \u0442.\u0434.) \u0442\u0435\u0433\u043e\u0432 tagDatabase<\/p>\n<figure class=\"full-width\"><\/figure>\n<\/li>\n<li>\n<p> \u041d\u0430\u043b\u0438\u0447\u0438\u0435 \u0431\u043b\u043e\u043a\u0430 <code>&lt;rollback&gt;<\/code> \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e changeSet.<\/p>\n<figure class=\"full-width\"><\/figure>\n<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0437\u0430 \u0432\u0441\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 CICD \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0443 \u043d\u0430\u0441 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 cli \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u043d\u0430 Python, \u0442\u043e \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e changelog.xml \u0431\u044b\u043b\u043e \u0434\u043e\u0432\u0435\u0440\u0435\u043d\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0435\u0439. \u0427\u0430\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u0430:<\/p>\n<details class=\"spoiler\">\n<summary>\u043a\u043e\u0434 \u0442\u0443\u0442\u044c<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import logging from enum import StrEnum from functools import cached_property  from lxml import etree   class ValidateUniqIdsError(Exception):     def __str__(self):         return (             \"\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 changeset ID \u043d\u0435 \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u0430! \"             \"\u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0447\u0442\u043e  \u0432\u0441\u0435 id changeset'\u043e\u0432 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438.\"         )   class ValidateChangesetIdsAscendingError(Exception):     def __str__(self):         return (             \"\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 ID changeset \u0431\u0434 \u043d\u0435 \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u0430! \"             \"\u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0447\u0442\u043e \u0432\u0441\u0435 ID \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044f.\"         )   class ValidateTagVersionsAscendingError(Exception):     def __str__(self):         return (             \"\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 tag version \u0441\u0445\u0435\u043c\u044b \u0411\u0414  \u043d\u0435 \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u0430! \u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0447\u0442\u043e \u0432\u0441\u0435 tag \"             \"version \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044f.\"         )   class ValidateUniqTagVersionsError(Exception):     def __str__(self):         return (             \"\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 tag version \u0441\u0445\u0435\u043c\u044b \u0411\u0414  \u043d\u0435 \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u0430. \u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0447\u0442\u043e \u0432\u0441\u0435 tag \"             \"version \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438.\"         )   class ValidateAreValuesIncrementingByOneError(Exception):     def __init__(self, tag_id: int):         self.tag_id = tag_id      def __str__(self):         return (             f\"TAG: {self.tag_id}  \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e TAG'\u0430 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u043d\u0430 1. \"             f\"\u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 rollback \u0434\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0411\u0414.\"         )   class ValidateExistenceRollbackInChangesetError(Exception):     def __init__(self, changeset_id: int):         self.changeset_id = changeset_id      def __str__(self):         return (             f\"\u0432 ChangeSet c ID: {self.changeset_id} \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c &lt;rollback&gt;&lt;\/rollback&gt; \"             f\"\u0431\u043b\u043e\u043a \u0441  SQL \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c \u043e\u0442\u043a\u0430\u0442\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.\"         )   class LiquiShit(StrEnum):     common = \"{http:\/\/www.liquibase.org\/xml\/ns\/dbchangelog}\"     rollback = f\"{common}rollback\"     sql_file = f\"{common}sqlFile\"     changeset = f\"{common}changeSet\"     tag_database = f\"{common}tagDatabase\"   class LiquibaseChangelogWorker:     def __init__(self, changelog_filename: str):         self.changelog_filename = changelog_filename      @cached_property     def xml_tree(self):         return etree.parse(self.changelog_filename).getroot()      @cached_property     def all_changesets(self):         return self.xml_tree.findall(LiquiShit.changeset)      @cached_property     def all_tags(self):         return [             int(changeset[0].get(\"tag\"))             for changeset in self.all_changesets             if changeset.findall(LiquiShit.tag_database)         ]      @cached_property     def all_sql_changesets(self):         return [             changeset             for changeset in self.all_changesets             if changeset.findall(LiquiShit.sql_file)         ]      @cached_property     def all_changeset_ids(self) -&gt; list:         return [             int(changeset.attrib.get(\"id\"))             for changeset in self.all_changesets         ]      def get_last_tag(self) -&gt; str:         return str(self.all_tags[-1])      def validate_uniq_ids(self) -&gt; None:          if len(self.all_changeset_ids) == len(set(self.all_changeset_ids)):             logging.info(\"\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f uniq changeset ID \u043f\u0440\u043e\u0448\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e!\")             return         raise ValidateUniqIdsError      def validate_changeset_ids_ascending(self):         if self.all_changeset_ids == sorted(self.all_changeset_ids):             logging.info(                 \"\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 ID changeset  \u043f\u0440\u043e\u0448\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e!\"             )             return         raise ValidateChangesetIdsAscendingError      def validate_tag_versions_ascending(self) -&gt; None:         if self.all_tags == sorted(self.all_tags):             logging.info(                 \"\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 tag version \u0441\u0445\u0435\u043c\u044b \u0411\u0414 \u043f\u0440\u043e\u0448\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e!\"             )             return         raise ValidateTagVersionsAscendingError      def validate_uniq_tag_versions(self) -&gt; None:         if len(self.all_tags) == len(set(self.all_tags)):             logging.info(                 \"\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 tag version \u0441\u0445\u0435\u043c\u044b \u0411\u0414 \u043f\u0440\u043e\u0448\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e!\"             )             return         raise ValidateUniqTagVersionsError      def validate_are_values_incrementing_by_one(self) -&gt; None:         for index, _tag in enumerate(self.all_tags[:-1]):             if self.all_tags[index] + 1 != self.all_tags[index + 1]:                 raise ValidateAreValuesIncrementingByOneError(                     self.all_tags[index + 1]                 )         logging.info(             \"\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u043d\u0430 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0435 \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u0435 tag version \u043f\u0440\u043e\u0448\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e!\"         )      def validate_existence_rollback_in_changeset(self) -&gt; None:         for sql_changeset in self.all_sql_changesets:             if not sql_changeset.findall(LiquiShit.rollback):                 raise ValidateExistenceRollbackInChangesetError(                     sql_changeset.attrib.get(\"id\")                 )         logging.info(             \"\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0432 ChangeSet \u0431\u043b\u043e\u043a\u0430 \u0441 rollback \u043f\u0440\u043e\u0448\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e!\"         ) <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h4>Deploy Dev, Stage, Prod. \u0412\u044b\u043a\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043d\u0430 \u043a\u043e\u043d\u0442\u0443\u0440 dev\/stg\/prod<\/h4>\n<pre><code class=\"yaml\">script:   - liquibase update --changelog-file=changelog-master.xml --username=$CLICKHOUSE_USER --password=$CLICKHOUSE_PASSWORD --url=jdbc:clickhouse:\/\/$CLICKHOUSE_HOST:$CLICKHOUSE_PORT\/$CLICKHOUSE_DB_NAME --driver=com.clickhouse.jdbc.ClickHouseDriver --defaultSchemaName=$CLICKHOUSE_DB_NAME  --logLevel=OFF<\/code><\/pre>\n<h4>Rollback Dev, Stage, Prod<\/h4>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c \u0431\u043b\u043e\u043a\u0430\u043c &lt;rollback&gt; , \u043d\u0430\u043b\u0438\u0447\u0438\u044e \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u043c\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c \u0432 SQL \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 \u043e\u0442\u043a\u0430\u0442\u0430, tagDatabase GitlabJob \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043a\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 (\u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u0438 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u043b\u0438\u0441\u044c tagDatabase). \u0422\u0430\u043a\u0436\u0435 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0436\u0435\u0441\u0442\u043a\u043e\u0439 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 changelog.xml \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0411\u0414 \u043d\u0430 1 \u043c\u0435\u043d\u044c\u0448\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0439, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u0435\u0442 \u043b\u043e\u0433\u0438\u043a\u0443 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 rollback<\/p>\n<pre><code class=\"yaml\">script:   - ROLLBACK_TO_VERSION=$((LAST_TAG_DB-1))   - liquibase rollback --tag=${ROLLBACK_TO_VERSION} --changelog-file=changelog-master.xml --username=$CLICKHOUSE_USER --password=$CLICKHOUSE_PASSWORD --url=jdbc:clickhouse:\/\/$CLICKHOUSE_HOST:$CLICKHOUSE_PORT\/$CLICKHOUSE_DB_NAME<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-447132","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/447132","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=447132"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/447132\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=447132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=447132"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=447132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}