Created
February 2, 2022 12:25
-
-
Save marvinhosea/34010552b3246b2dad442dff0d25804d to your computer and use it in GitHub Desktop.
Liquibase Changelog Name Convention Using Date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
while getopts c:u: flag | |
do | |
case "${flag}" in | |
c) changelogname=${OPTARG};; | |
u) username=${OPTARG};; | |
esac | |
done | |
if [ -z $changelogname ]; then | |
echo "changelog name not provided" | |
exit 1 | |
fi | |
if [ -z $username ]; then | |
username=$USER | |
fi | |
current_time=$(date "+%Y_%m_%d_%H%M%S") | |
new_fileName="_"$changelogname"_changelog.sql" | |
converted="$(echo $new_fileName | sed 's/\([^A-Z]\)\([A-Z0-9]\)/\1_\2/g' \ | |
| sed 's/\([A-Z0-9]\)\([A-Z0-9]\)\([^A-Z]\)/\1_\2\3/g' \ | |
| tr '[:upper:]' '[:lower:]')" | |
echo "--liquibase formatted sql | |
--changeset $username:1 | |
-- rollback " > ../db/liquibase/changelog/$current_time$converted | |
echo "Changelog created successfully : $current_time$converted" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Created this bash script to help create liquibase changelogs based on time. This is important when you're working with a team.