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.components.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              maxLength = 255
46      )
47      @NotNull
48      @Size(max = 255)
49      /**
50       * @return Value from the changeset id attribute.
51       */
52      String getId();
53  
54      /**
55       * @return Value from the changeset author attribute.
56       */
57      @Schema(
58              title = "Author",
59              description = "Value from the changeset author attribute.",
60              required = true,
61              maxLength = 255
62      )
63      @Size(max = 255)
64      String getAuthor();
65  
66      /**
67       * Path to the changelog. This may be an absolute path or a relative path depending on how the changelog was passed
68       * to Liquibase. For best results, it should be a relative path. The logicalFilePath attribute can be used on the
69       * changelog or on individual changesets.
70       *
71       * @return Path to the changelog.
72       */
73      @Schema(
74              title = "Path to the changelog",
75              description = "Path to the changelog. This may be an absolute path or a relative path depending on how " +
76                      "the changelog was passed to Liquibase. For best results, it should be a relative path. The " +
77                      "logicalFilePath attribute can be used on the changelog or on individual changesets.",
78              required = true,
79              maxLength = 255
80      )    @Size(max = 255)
81      @NotNull
82      String getFilename();
83  
84      /**
85       * @return Date/time of when the changeset was executed. Used with {@link #getExecutionOrder()} to determine
86       * rollback order.
87       */
88      @Schema(
89              title = "Execution Date",
90              description = "Date/time of when the changeset was executed. Used with {@link #getExecutionOrder()} to " +
91                      "determine rollback order.",
92              required = true,
93              pattern = "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{3}(Z|(+|-)\\d{2}:\\d{2})$",
94              maxLength = 255
95      )
96      @NotNull
97      @Size(max = 255)
98      OffsetDateTime getExecutionDate();
99  
100     /**
101      * <p>Order that the changesets were executed. Used in addition to {@link #getExecutionDate()} to ensure order
102      * is correct even when the databases datetime supports poor resolution.</p>
103      *
104      * <p><b>NOTE:</b> The values are only guaranteed to be increasing within an individual update run. There are times
105      * where they will restart at zero.</p>
106      *
107      * @return Order that the changesets were executed.
108      */
109     @Schema(
110             title = "Execution Order",
111             description = "Order that the changesets were executed. Used in addition to the Execution Date to " +
112                     "ensure order is correct even when the databases datetime supports poor resolution. NOTE: The " +
113                     "values are only guaranteed to be increasing within an individual update run. There are times " +
114                     "where they will restart at zero.",
115             required = true,
116             minimum = "0"
117     )
118     int getExecutionOrder();
119 
120     /**
121      * Description of how the changeset was executed.
122      *
123      * @return Description of how the changeset was executed.
124      */
125     @NotNull
126     ExecType getExecutionType();
127 
128     /**
129      * Checksum of the changeset when it was executed. Used on each run to ensure there have been no unexpected changes
130      * to changesets in the changelog file.
131      *
132      * @return Checksum of the changeset when it was executed.
133      */
134     @Schema(
135             title = "MD5 Sum",
136             description = "Checksum of the changeset when it was executed. Used on each run to ensure there have " +
137                     "been no unexpected changes to changesets in the changelog file.",
138             required = true,
139             minLength = 32,
140             maxLength = 35
141     )
142     @NotNull
143     @Size(max = 35)
144     String getMd5Sum();
145 
146     /**
147      * @return Short auto-generated human-readable description of changeset
148      */
149     @Schema(
150             title = "Description",
151             description = "Short auto-generated human-readable description of changeset.",
152             required = true,
153             minLength = 1,
154             maxLength = 255
155     )
156     @NotNull
157     @Size(max = 255)
158     String getDescription();
159 
160     /**
161      * @return Value from the changeset comment attribute.
162      */
163     @Schema(
164             title = "Comments",
165             description = "Value from the changeset comment attribute.",
166             required = true,
167             maxLength = 255
168     )
169     @Size(max = 255)
170     String getComments();
171 
172     /**
173      * @return Tracks which changeset correspond to tag operations.
174      */
175     @Schema(
176             title = "Tag",
177             description = "Tracks which changeset correspond to tag operations.",
178             maxLength = 255
179     )
180     @Size(max = 255)
181     String getTag();
182 
183     /**
184      * @return Version of Liquibase used to execute the changeset.
185      */
186     @Schema(
187             title = "Liquibase Version",
188             description = "Version of Liquibase used to execute the changeset.",
189             required = true,
190             maxLength = 255
191     )
192     @NotNull
193     @Size(max = 20)
194     String getLiquibaseVersion();
195 
196     /**
197      * @return Context(s) used to execute the changeset.
198      */
199     @Schema(
200             title = "Context(s)",
201             description = "Context(s) used to execute the changeset.",
202             maxLength = 255
203     )
204     @Size(max = 255)
205     String getContexts();
206 
207     /**
208      * @return Label(s) used to execute the changeset.
209      */
210     @Schema(
211             title = "Label(s)",
212             description = "Label(s) used to execute the changeset.",
213             maxLength = 255
214     )
215     @Size(max = 255)
216     String getLabels();
217 
218     /**
219      * @return changesets deployed together will have the same unique identifier.
220      */
221     @Schema(
222             title = "Deployment Id",
223             description = "changesets deployed together will have the same unique identifier.",
224             required = true,
225             maxLength = 10
226     )
227     @NotNull
228     @Size(max = 10)
229     String getDeploymentId();
230 
231 
232     /**
233      * The liquibase execution type.
234      *
235      * @author klenkes74 {@literal <rlichti@kaiserpfalz-edv.de>}
236      * @since 3.0.0  2023-01-19
237      */
238     @Schema(
239             title = "Execution Type",
240             description = "Description of how the changeset was executed.",
241             required = true,
242             enumeration = {"EXECUTED","FAILED","SKIPPED","RERAN","MARK_RAN"}
243     )
244     enum ExecType {
245         EXECUTED, FAILED, SKIPPED, RERAN, MARK_RAN
246     }
247 }