Applies to
- Liquibase Pro
- Liquibase Open Source (Community)
Conditions
- Using a Liquibase rollback command
- Using
sqlFileor similar attributes in changesets that reference external SQL files for rollback
Issue Summary
When executing a Liquibase rollback command with a tag, the rollback operation fails with an error indicating that a SQL file cannot be found in the configured search path. The file appears to exist in the expected location, but Liquibase is unable to locate it during the rollback process. This issue occurs even though the liquibase update command previously executed successfully.
Error Message
liquibase.exception.CommandExecutionException: liquibase.exception.LiquibaseException: liquibase.exception.RollbackFailedException: liquibase.exception.RollbackFailedException: Rollback statement failed validation: The file rollback/example_rollback_file.sql was not found in the configured search path:
- /path/to/working/directory
Root Cause
This issue can occur due to one of the following root causes:
-
File Name Mismatch: The most common cause is a discrepancy between the file name referenced in the changelog and the actual file name on disk. This often involves:
- Typos or spelling differences
- Extra or missing underscores, hyphens, or other special characters
- Case sensitivity issues on certain operating systems
- File extension differences
-
Incorrect Search Path: The file exists but is not located within Liquibase's configured search path. When no search path is explicitly configured, Liquibase defaults to searching in:
- The Liquibase installation directory
- The current working directory where the command is executed
- Different Working Directory: The rollback command is being executed from a different working directory than the update command, causing Liquibase to search in a different location.
- Missing Directory Structure: The directory structure containing the rollback file does not exist in the expected location relative to the working directory.
Resolution
Follow these troubleshooting steps to resolve the issue:
Step 1: Verify the Exact File Name
- Review the error message to identify the file name that Liquibase is searching for
- Navigate to the directory where the file should exist
- Compare the file name character-by-character with the name referenced in your changelog:
- Check for extra or missing underscores (
_), hyphens (-), or other special characters - Verify the spelling is identical
- Confirm the file extension matches exactly (e.g.,
.sql) - On case-sensitive systems (Linux/Unix), ensure the case matches exactly
- Check for extra or missing underscores (
Example of common file name issues:
- Changelog references:
rollback/example_rollback_file.sql - Actual file name:
rollback/example__rollback_file.sql(note the double underscore)
Step 2: Verify the Search Path
- Review your Liquibase logs to identify the configured search path:
FINE [liquibase.resource] Overall search path: - /path/to/working/directory- You may also review the value set for the search path.
- Confirm that your rollback directory and file exist within one of the listed search path locations.
- Verify the directory structure. For example, if the error references
rollback/example_rollback_file.sql, ensure:- A
rollbacksubdirectory exists in your working directory - The SQL file exists within that
rollbacksubdirectory
- A
Step 3: Configure the Search Path (if needed)
If your rollback files are located outside the default search path, add the path to your Liquibase configuration:
Option 1: Using command-line parameter
liquibase --search-path=/path/to/rollback/files rollback --tag=TAG_NAMEOption 2: Using liquibase.properties file
liquibase.searchPath=/path/to/rollback/files,/path/to/another/directory
Option 3: Using environment variable
export LIQUIBASE_SEARCH_PATH=/path/to/rollback/files
Note: Multiple paths can be separated by commas or semicolons (depending on OS).
Step 4: Verify Working Directory Consistency
Ensure you're executing the rollback command from the same working directory that was used during the update command:
- Review the logs from your successful
liquibase updatecommand - Compare the search path from the update logs with the rollback logs
- Execute the rollback command from the same location as the update command
Step 5: Correct the Issue
Based on your findings:
If the file name is incorrect:
- Rename the file on disk to match the changelog reference exactly, OR
- Update the changelog file to reference the correct file name
If the search path is incorrect:
- Configure the search path as described in Step 3, OR
- Move the rollback files to a location within the existing search path
Step 6: Test the Rollback
After making corrections, test the rollback command again:
liquibase rollback --tag=TAG_NAMEReview the logs to confirm the file is found successfully.
Comments
0 comments
Article is closed for comments.