Class DBSchema


  • public final class DBSchema
    extends Object
    Database schema creator.
    • Field Detail

      • DB_VERSIONING_STARTED_VERSION

        public static final int DB_VERSIONING_STARTED_VERSION
        The version when the DB_Version table was created and DB version saved in DB.
        See Also:
        Constant Field Values
    • Method Detail

      • getCurrentVersion

        public static int getCurrentVersion()
      • hasIncompatibleSchemaChanges

        public static boolean hasIncompatibleSchemaChanges​(@NotNull
                                                           DBFunctions dbf,
                                                           int sinceVersion)
        Returns true if since specified version there was at least one converter which made an incompatible schma change
        Parameters:
        sinceVersion - - since version (excluding)
        Returns:
        see above
      • getSchema

        @NotNull
        public static SchemaDef getSchema()
      • createSchemaTablesAndIndices

        public static void createSchemaTablesAndIndices​(DBFunctions dbf,
                                                        @NotNull
                                                        SchemaDef schema)
      • populateWithInitialData

        public static void populateWithInitialData​(@NotNull
                                                   DBFunctions dbf,
                                                   @NotNull
                                                   GuidGenerator guidGenerator)
      • createSchema

        public static void createSchema​(@NotNull
                                        DBFunctions dbf,
                                        @NotNull
                                        GuidGenerator guidGenerator,
                                        boolean withData)
      • loadDatabaseVersion

        public static int loadDatabaseVersion​(@NotNull
                                              DBFunctions dbf)
        Load the "data format" version from database.
        Parameters:
        dbf -
        Returns:
        the "data format" version, or 0 if not determined.
      • getLastConverterDate

        @Nullable
        public static Date getLastConverterDate​(@NotNull
                                                DBFunctions dbf)
        Parameters:
        dbf -
        Returns:
        date of the last applied converter.
        Since:
        2019.2
      • writeDatabaseVersion

        public static void writeDatabaseVersion​(@NotNull
                                                DBFunctions dbf,
                                                int newVersionNr,
                                                @Nullable
                                                Date timestamp)
      • writeDatabaseVersion

        public static void writeDatabaseVersion​(@NotNull
                                                DBFunctions dbf,
                                                int newVersionNr,
                                                @Nullable
                                                Date timestamp,
                                                boolean incompatibleChange)
      • loadDatabaseMetadataVersion

        public static int loadDatabaseMetadataVersion​(@NotNull
                                                      DBFunctions dbf)
      • storeCurrentMetadataIntoDatabase

        public static void storeCurrentMetadataIntoDatabase​(@NotNull
                                                            DBFunctions dbf)
      • loadMetadataFileFromDatabase

        public static String[] loadMetadataFileFromDatabase​(@NotNull
                                                            DBFunctions dbf,
                                                            String fileName)
      • clearAllMetadataInDatabase

        public static void clearAllMetadataInDatabase​(@NotNull
                                                      DBFunctions dbf)
      • guessSchemaBelongsToTeamcity

        public static boolean guessSchemaBelongsToTeamcity​(Set<String> tables)
        Analyzes schema tables and guesses whether the schema belongs to TeamCity or not. Should support TeamCity schemas since version 3.0.
        Parameters:
        tables - names of schema tables, in lower case.
        Returns:
        belongs to TeamCity.
      • generatePerSessionScript

        @NotNull
        public static String[] generatePerSessionScript​(@NotNull
                                                        DBFunctions dbf)