Class RepositoryDbMigration

  • All Implemented Interfaces:
    AutoCloseable

    public class RepositoryDbMigration
    extends ADbMigration
    Class with migration utils for Repository database.

    This class offers a main method to run that will migrate an existing ActiveMonitor Repository database to its new structure for the current version.
    This migrates a database with schema version 3.4, used by ActiveMonitor 3.4, to the current version.

    Haw to use it:
    Execute the main(String...) method. It uses connection information specified in repository.db.properties to connect to the database.

    This "script" suggests a solution to migrate your existing database. This must be read as advice on what to change more than an explicit tool for migration.
    It does not handle all types of database and is not designed to consider extra database customizations.
    Operations are performed in-place, meaning that it changes an existing database.It is strongly recommended to backup your database before running the migration process.
    Read the main(String...) method content to get the list of all transformations applied to the database. Each transformation is handled by a dedicated method, whose purpose is documented as most as possible.

    Main changes performed for this migration

    • Prefixing all table names

    For more information, consult our migration notes and release notes.

    Author:
    QuartetFS
    • Constructor Detail

      • RepositoryDbMigration

        public RepositoryDbMigration()
    • Method Detail

      • main

        public static void main​(String... args)
                         throws SQLException
        Runs the migration for Repository database.

        This migration is a lot heavier than preceding.
        A lot of operations involves migrating tables and columns to support automatically main databases systems, as well as being able to put all tables in the same schema.
        Hibernate was also migrated to a new major version, involving some changes on its internal behavior.
        Finally, new features of Repository require new tables or columns.

        Reading the following code and the doc of the called methods will give an overview of the operations performed to migrate the database.
        Given the complexity for some operations, some may not perform any action, or be restricted as an example to H2 database.

        Parameters:
        args - (nane expected)
        Throws:
        SQLException - if the connection has issues
      • addNullConstraintsOnParameters

        public void addNullConstraintsOnParameters()
        Makes fields name and coordinates of table ""repository_pointValues"" non nullable.

        This method is only defined for H2 because the statement requires to know the correct field type, that depends on the database and dialect.
        Yet, it is easily portable to any other DB.

      • migrateDbVersion

        public void migrateDbVersion()
        Updates the database version schema.