Sunday, December 3, 2023

Liquibase Usage

 

  1. Changeset Identifier:

    • David:96A507E7-F45F-4937-BF8C-5165201BB7CD
      • The changeset identifier uniquely identifies this changeset. It typically includes the author's name (David in this case) and a universally unique identifier (UUID) to ensure uniqueness.
  2. endDelimiter:

    • GO
      • The endDelimiter attribute specifies the delimiter that marks the end of the SQL statements within a changeset. In this case, it is set to GO. This is commonly used in SQL Server scripts.
  3. splitStatements:

    • true
      • The splitStatements attribute determines whether Liquibase should split SQL statements based on the specified endDelimiter. When set to true, Liquibase interprets each statement between delimiters as a separate SQL statement.
  4. stripComments:

    • false
      • The stripComments attribute controls whether Liquibase should remove comments from the SQL statements. When set to false, comments in the SQL script are retained.
  5. runAlways:

    • true
      • The runAlways attribute indicates that this changeset should be executed every time Liquibase runs, regardless of whether the changeset has been run before or not.
  6. runOnChange:

    • true
      • The runOnChange attribute specifies that the changeset should be executed if the changeset file has changed since the last execution. This is useful for scenarios where you want to rerun the changeset if it has been modified.
  7. failOnError:

    • false
      • The failOnError attribute determines whether Liquibase should halt the execution of the entire migration if an error occurs during the execution of this specific changeset. When set to false, Liquibase will log the error but continue with subsequent changesets.
       
    <changeSet id="David:96A507E7-F45F-4937-BF8C-5165201BB7CD"
               author="David"
               endDelimiter="GO"
               splitStatements="true"
               stripComments="false"
               runAlways="true"
               runOnChange="true"
               failOnError="false">
        <!-- Your SQL changes go here -->
    </changeSet>
     
  8. the NEWID() function in SQL Server is used to generate a new uniqueidentifier (UUID) value. If you want to generate a UUID similar to what you might use in Liquibase's changeset identifier, you can use the following SQL query:

SELECT NEWID() AS GeneratedUUID;
 96A507E7-F45F-4937-BF8C-5165201BB7CD

Replace the 96A507E7-F45F-4937-BF8C-5165201BB7CD part with the generated UUID from the SQL query. This ensures that each changeset has a unique identifier. Keep in mind that while the generated UUID may look different each time you run the query, it will still be a valid and unique identifier.