public class DatabaseUpdater extends Object
Modifier and Type | Class and Description |
---|---|
static class |
DatabaseUpdater.OpenMRSChangeSet
Represents each change in the files referenced by liquibase-update-to-latest
|
Modifier and Type | Field and Description |
---|---|
static String |
CONTEXT |
static String |
DATABASE_UPDATES_LOG_FILE |
Constructor and Description |
---|
DatabaseUpdater() |
Modifier and Type | Method and Description |
---|---|
static Boolean |
allowAutoUpdate()
Indicates whether automatic database updates are allowed by this server.
|
static void |
executeChangelog()
Convenience method to run the changesets using Liquibase to bring the database up to a version
compatible with the code
|
static List<String> |
executeChangelog(String changelog,
ChangeSetExecutorCallback callback)
Executes the given changelog file.
|
static List<String> |
executeChangelog(String changeLogFile,
liquibase.Contexts contexts,
ChangeSetExecutorCallback callback,
ClassLoader cl)
This code was borrowed from the liquibase jar so that we can call the given callback function.
|
static void |
executeChangelog(String changelog,
Map<String,Object> userInput)
Deprecated.
as of 2.4 see
executeChangelog(String, ChangeSetExecutorCallback) |
static Integer |
getAuthenticatedUserId() |
static Connection |
getConnection()
Gets a database connection for liquibase to do the updates
|
static List<DatabaseUpdater.OpenMRSChangeSet> |
getDatabaseChanges()
Returns all change sets defined by (a) the Liquibase snapshot files that had been used to
initialise the OpenMRS database and (b) the Liquibase update files that that are applicable on
top of the snapshot version.
|
static List<DatabaseUpdater.OpenMRSChangeSet> |
getUnrunDatabaseChanges(LiquibaseProvider liquibaseProvider)
Returns a list of Liquibase change sets were not run yet.
|
static List<DatabaseUpdater.OpenMRSChangeSet> |
getUnrunDatabaseChanges(String... changeLogFilenames)
Looks at the specified liquibase change log files and returns all changesets in the files that
have not been run on the database yet.
|
static boolean |
isLocked()
This method currently checks the liquibasechangeloglock table to see if there is a row with a
lock in it.
|
static void |
releaseDatabaseLock()
This method releases the liquibase db lock after a crashed database update.
|
static void |
reportUpdateWarnings(List<String> warnings)
This method is called by an executing custom changeset to register warning messages.
|
static void |
setAuthenticatedUserId(Integer userId) |
static boolean |
updatesRequired()
Ask Liquibase if it needs to do any updates.
|
static boolean |
updatesRequired(String... changeLogFilenames)
Ask Liquibase if it needs to do any updates
|
static void |
writeUpdateMessagesToFile(String text)
This method writes the given text to the database updates log file located in the application
data directory.
|
public static final String CONTEXT
public static final String DATABASE_UPDATES_LOG_FILE
public static void executeChangelog() throws DatabaseUpdateException
DatabaseUpdateException
@Deprecated public static void executeChangelog(String changelog, Map<String,Object> userInput) throws DatabaseUpdateException
executeChangelog(String, ChangeSetExecutorCallback)
changelog
- the liquibase changelog file to use (or null to use the default file)userInput
- nullable map from question to user answer. Used if a call to update(null) threw
an InputRequiredException
DatabaseUpdateException
- if an error occurspublic static List<String> executeChangelog(String changelog, ChangeSetExecutorCallback callback) throws DatabaseUpdateException
changelog
- The string filename of a liquibase changelog xml file to runDatabaseUpdateException
public static List<String> executeChangelog(String changeLogFile, liquibase.Contexts contexts, ChangeSetExecutorCallback callback, ClassLoader cl) throws Exception
changeLogFile
- the file to executecontexts
- the liquibase changeset contextcallback
- the function to call after every changesetException
public static boolean updatesRequired() throws Exception
Exception
- when an exception is raised while processing Liquibase changelog filespublic static boolean updatesRequired(String... changeLogFilenames) throws Exception
changeLogFilenames
- the filenames of all files to search for unrun changesetsException
public static Boolean allowAutoUpdate()
public static Connection getConnection() throws Exception
Exception
public static List<DatabaseUpdater.OpenMRSChangeSet> getDatabaseChanges() throws Exception
Exception
public static List<DatabaseUpdater.OpenMRSChangeSet> getUnrunDatabaseChanges(LiquibaseProvider liquibaseProvider) throws Exception
liquibaseProvider
- provides access to a Liquibase instanceException
public static List<DatabaseUpdater.OpenMRSChangeSet> getUnrunDatabaseChanges(String... changeLogFilenames)
changeLogFilenames
- the filenames of all files to search for unrun changesetspublic static Integer getAuthenticatedUserId()
public static void setAuthenticatedUserId(Integer userId)
userId
- the authenticatedUserId to setpublic static void reportUpdateWarnings(List<String> warnings)
warnings
- list of warnings to append to the end of the current listpublic static void writeUpdateMessagesToFile(String text)
text
- text to be written to the filepublic static void releaseDatabaseLock() throws liquibase.exception.LockException
liquibase.exception.LockException
public static boolean isLocked()
Copyright © 2024 OpenMRS Inc.. All rights reserved.