View Javadoc
1   /*
2    * Copyright (c) 2023. Roland T. Lichti, Kaiserpfalz EDV-Service.
3    *
4    * This program is free software: you can redistribute it and/or modify
5    * it under the terms of the GNU General Public License as published by
6    * the Free Software Foundation, either version 3 of the License, or
7    * (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program.  If not, see <https://www.gnu.org/licenses/>.
16   */
17  
18  package de.kaiserpfalzedv.commons.api.liquibase.model;
19  
20  import org.eclipse.microprofile.openapi.annotations.media.Schema;
21  
22  import jakarta.validation.constraints.NotNull;
23  import jakarta.validation.constraints.Size;
24  import java.time.OffsetDateTime;
25  
26  /**
27   * <p>ChangeLog -- The liquibase changelog.</p>
28   *
29   * <p>This is the interface description to the changelog table as described in the
30   * <a href="https://docs.liquibase.com/concepts/tracking-tables/databasechangelog-table.html">liquibase
31   * documentation</a>.</p>
32   *
33   * @author klenkes74 {@literal <rlichti@kaiserpfalz-edv.de>}
34   * @since 3.0.0  2023-01-19
35   */
36  @Schema(
37          name = "Liquibase Changelog",
38          description = "This is the interface description to the changelog table as described in the liquibase documentation"
39  )
40  public interface ChangeLog {
41      @Schema(
42              title = "Id",
43              description = "Value from the changeset id attribute.",
44              required = true,
45              example = "20230118-rlichti-001",
46              maxLength = 255
47      )
48      @NotNull
49      @Size(max = 255)
50      /**
51       * @return Value from the changeset id attribute.
52       */
53      String getId();
54  
55      /**
56       * @return Value from the changeset author attribute.
57       */
58      @Schema(
59              title = "Author",
60              description = "Value from the changeset author attribute.",
61              required = true,
62              example = "rlichti",
63              maxLength = 255
64      )
65      @Size(max = 255)
66      String getAuthor();
67  
68      /**
69       * Path to the changelog. This may be an absolute path or a relative path depending on how the changelog was passed
70       * to Liquibase. For best results, it should be a relative path. The logicalFilePath attribute can be used on the
71       * changelog or on individual changesets.
72       *
73       * @return Path to the changelog.
74       */
75      @Schema(
76              title = "Path to the changelog",
77              description = "Path to the changelog. This may be an absolute path or a relative path depending on how " +
78                      "the changelog was passed to Liquibase. For best results, it should be a relative path. The " +
79                      "logicalFilePath attribute can be used on the changelog or on individual changesets.",
80              required = true,
81              example = "db/changelog/base-structure.xml",
82              maxLength = 255
83      )    @Size(max = 255)
84      @NotNull
85      String getFilename();
86  
87      /**
88       * @return Date/time of when the changeset was executed. Used with {@link #getExecutionOrder()} to determine
89       * rollback order.
90       */
91      @Schema(
92              title = "Execution Date",
93              description = "Date/time of when the changeset was executed. Used with {@link #getExecutionOrder()} to " +
94                      "determine rollback order.",
95              required = true,
96              pattern = "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{3}(Z|(+|-)\\d{2}:\\d{2})$",
97              example = "2023-01-19T01:00:00.000Z",
98              maxLength = 255
99      )
100     @NotNull
101     @Size(max = 255)
102     OffsetDateTime getExecutionDate();
103 
104     /**
105      * <p>Order that the changesets were executed. Used in addition to {@link #getExecutionDate()} to ensure order
106      * is correct even when the databases datetime supports poor resolution.</p>
107      *
108      * <p><b>NOTE:</b> The values are only guaranteed to be increasing within an individual update run. There are times
109      * where they will restart at zero.</p>
110      *
111      * @return Order that the changesets were executed.
112      */
113     @Schema(
114             title = "Execution Order",
115             description = "Order that the changesets were executed. Used in addition to the Execution Date to " +
116                     "ensure order is correct even when the databases datetime supports poor resolution. NOTE: The " +
117                     "values are only guaranteed to be increasing within an individual update run. There are times " +
118                     "where they will restart at zero.",
119             required = true,
120             example = "5",
121             minimum = "0"
122     )
123     int getExecutionOrder();
124 
125     /**
126      * Description of how the changeset was executed.
127      *
128      * @return Description of how the changeset was executed.
129      */
130     @NotNull
131     ExecType getExecutionType();
132 
133     /**
134      * Checksum of the changeset when it was executed. Used on each run to ensure there have been no unexpected changes
135      * to changesets in the changelog file.
136      *
137      * @return Checksum of the changeset when it was executed.
138      */
139     @Schema(
140             title = "MD5 Sum",
141             description = "Checksum of the changeset when it was executed. Used on each run to ensure there have " +
142                     "been no unexpected changes to changesets in the changelog file.",
143             required = true,
144             example = "a3cca2b2aa1e3b5b3b5aad99a8529074",
145             minLength = 32,
146             maxLength = 35
147     )
148     @NotNull
149     @Size(max = 35)
150     String getMd5Sum();
151 
152     /**
153      * @return Short auto-generated human-readable description of changeset
154      */
155     @Schema(
156             title = "Description",
157             description = "Short auto-generated human-readable description of changeset.",
158             required = true,
159             minLength = 1,
160             maxLength = 255
161     )
162     @NotNull
163     @Size(max = 255)
164     String getDescription();
165 
166     /**
167      * @return Value from the changeset comment attribute.
168      */
169     @Schema(
170             title = "Comments",
171             description = "Value from the changeset comment attribute.",
172             required = true,
173             maxLength = 255
174     )
175     @Size(max = 255)
176     String getComments();
177 
178     /**
179      * @return Tracks which changeset correspond to tag operations.
180      */
181     @Schema(
182             title = "Tag",
183             description = "Tracks which changeset correspond to tag operations.",
184             maxLength = 255
185     )
186     @Size(max = 255)
187     String getTag();
188 
189     /**
190      * @return Version of Liquibase used to execute the changeset.
191      */
192     @Schema(
193             title = "Liquibase Version",
194             description = "Version of Liquibase used to execute the changeset.",
195             required = true,
196             maxLength = 255
197     )
198     @NotNull
199     @Size(max = 20)
200     String getLiquibaseVersion();
201 
202     /**
203      * @return Context(s) used to execute the changeset.
204      */
205     @Schema(
206             title = "Context(s)",
207             description = "Context(s) used to execute the changeset.",
208             maxLength = 255
209     )
210     @Size(max = 255)
211     String getContexts();
212 
213     /**
214      * @return Label(s) used to execute the changeset.
215      */
216     @Schema(
217             title = "Label(s)",
218             description = "Label(s) used to execute the changeset.",
219             maxLength = 255
220     )
221     @Size(max = 255)
222     String getLabels();
223 
224     /**
225      * @return changesets deployed together will have the same unique identifier.
226      */
227     @Schema(
228             title = "Deployment Id",
229             description = "changesets deployed together will have the same unique identifier.",
230             required = true,
231             maxLength = 10
232     )
233     @NotNull
234     @Size(max = 10)
235     String getDeploymentId();
236 
237 
238     /**
239      * The liquibase execution type.
240      *
241      * @author klenkes74 {@literal <rlichti@kaiserpfalz-edv.de>}
242      * @since 3.0.0  2023-01-19
243      */
244     @Schema(
245             title = "Execution Type",
246             description = "Description of how the changeset was executed.",
247             required = true,
248             example = "MARK_RAN",
249             enumeration = {"EXECUTED","FAILED","SKIPPED","RERAN","MARK_RAN"}
250     )
251     enum ExecType {
252         EXECUTED, FAILED, SKIPPED, RERAN, MARK_RAN
253     }
254 }