2019-12-13 01:14:29 +01:00
|
|
|
#! /bin/bash
|
2023-05-10 20:45:19 +02:00
|
|
|
|
|
|
|
validate-number(){
|
|
|
|
re='^[0-9]+$'
|
|
|
|
if [[ ! $1 =~ $re ]]; then
|
|
|
|
echo "Error: The value must be a number." >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-12-13 01:14:29 +01:00
|
|
|
g-migration() {
|
|
|
|
[[ -z "$1" ]] && { echo "Migration version is required!" ; exit 1; }
|
|
|
|
local vnum=$1
|
2023-05-10 20:45:19 +02:00
|
|
|
|
|
|
|
validate-number "$vnum"
|
|
|
|
|
2019-12-13 01:14:29 +01:00
|
|
|
if (($1 < 100)); then
|
|
|
|
vnum=0$1
|
|
|
|
fi
|
2023-05-10 20:45:19 +02:00
|
|
|
touch app/scripts/migrations/"$vnum".ts
|
|
|
|
cp app/scripts/migrations/template.ts app/scripts/migrations/"$vnum".ts
|
2019-12-13 01:14:29 +01:00
|
|
|
|
2021-03-17 05:21:46 +01:00
|
|
|
touch app/scripts/migrations/"$vnum".test.js
|
|
|
|
cp app/scripts/migrations/template.test.js app/scripts/migrations/"$vnum".test.js
|
2019-12-13 01:14:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
g-migration "$1"
|