Record Class StarterFlywayModule

java.lang.Object
java.lang.Record
com.vireocode.vireo.flyway.StarterFlywayModule
Record Components:
name - short module name, for example auth
order - relative order across modules. Lower runs first. Only matters where one module's tables have foreign keys into another's: history, saved_filter and sync_command all reference app_user, so auth migrates first.

public record StarterFlywayModule(String name, int order) extends Record
A module's claim on a set of database tables.

Library-owned tables need library-owned migrations, and the dangerous way to do that is to drop them into the consumer's db/migration folder and share one flyway_schema_history. Version numbers would then be a shared namespace between two independently released codebases: the library ships V2, the consumer already applied V20260801120000, and the upgrade is an out-of-order migration against a live database.

So each module migrates separately, into its own history table. The library and the consumer can then both number their migrations from one and never meet.

Everything is derived from name() by convention, because a mis-declared history table would be discovered in production rather than in a build.

  • Constructor Details

    • StarterFlywayModule

      public StarterFlywayModule(String name, int order)
      Creates an instance of a StarterFlywayModule record class.
      Parameters:
      name - the value for the name record component
      order - the value for the order record component
  • Method Details

    • commonLocation

      public String commonLocation()
      Migrations every database gets.
    • vendorLocation

      public String vendorLocation(String vendor)
      Migrations only one database vendor gets, mirroring the classpath:db/vendor/{vendor} convention consumers already use. Absent directories are not an error.
    • historyTable

      public String historyTable()
      Never flyway_schema_history. That one belongs to the consumer.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • order

      public int order()
      Returns the value of the order record component.
      Returns:
      the value of the order record component