-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·62 lines (48 loc) · 2.01 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
[[ -n "${DEBUG}" ]] && set -o xtrace
set -o errexit
set -o pipefail
target="${PWD}"
target_name=$(basename ${target})
db_path="${target}/db"
function err() {
echo $*
exit 1
}
[[ -d ${db_path} ]] && err "${db_path} already exists, aborting..."
[[ -f "add-migration.sh" ]] && err "add-migration.sh already exists, aborting..."
[[ -f "docker-compose.yml" ]] && err "docker-compose.yml already exists, aborting..."
temp=$(mktemp -d)
echo ''
echo ' ( * ( ( ( ) ) '
echo ' )\ ) ( ( ` )\ ) ( )\ ) ( * ))\ ) ( /( ( /( '
echo '(()/( ( )\ )\))( (()/( )\ ) (()/( )\ ` ) /(()/( )\()) )\()) '
echo ' /(_)))((_) ((_)()\ /(_)|()/( /(_)|(((_)( ( )(_))(_)|(_)\ ((_)\ '
echo '(_))_((_)_ (_()((_|_)) /(_))_(_)) )\ _ )\(_(_()|_)) ((_) _((_) '
echo ' | \| _ ) | \/ |_ _|(_)) __| _ \ (_)_\(_)_ _|_ _| / _ \| \| | '
echo ' | |) | _ \ | |\/| || | | (_ | / / _ \ | | | | | (_) | .` | '
echo ' |___/|___/ |_| |_|___| \___|_|_\ /_/ \_\ |_| |___| \___/|_|\_| '
echo ' '
echo ''
echo "Installing database migration in '${target_name}'..."
pushd ${temp} 1>/dev/null
curl -s https://api.github.com/repos/dfds/pgup/releases/latest | \
grep "tarball_url" | \
cut -d '"' -f 4 | \
xargs curl -o pgup.tar.gz -sSL
tar xzf pgup.tar.gz --strip-component 1
popd 1>/dev/null
cp -r ${temp}/db ${target}
cp -r ${temp}/install/* ${target}
rm -rf ${temp}
echo
echo "The following directories and files have been added:"
echo
echo "${target_name}"
echo "├ db/ # database migration root"
echo "│ ├ migrations/ # contains example migration scripts"
echo "│ └ seed/ # contains example seed data"
echo "├ add-migration.sh # use this script to add migrations"
echo "└ docker-compose.yaml # example of database and migration container"
echo
echo "\033[1m** NOTE: remember to remove any example scripts before committing...\033[0m"