blob: 83f15a2bab694db59bdc8c31eebeb4ba54f28b14 (
plain) (
blame)
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
|
#!/bin/sh
if [ ! -z "$1" ]
then
FILENAME="$1"
echo "Using filename: $FILENAME"
else
read -p "Enter migration filename: " FILENAME
fi
[ -f ".env" ] && (
mv .env .env.tmp
source .env.tmp
)
make_migration() {
echo "Creating migrations for $2"
mkdir "../util/src/migrations/$2"
# npm run build clean logerrors pretty-errors
# THREADS=1 DATABASE="$1" DB_MIGRATE=a npm run start:bundle
THREADS=1 DATABASE="$1" DB_MIGRATE=a npx typeorm-ts-node-commonjs migration:generate "../util/src/migrations/$2/$FILENAME" -d ../util/src/util/Database.ts -p
npm run build clean logerrors pretty-errors
THREADS=1 DATABASE="$1" DB_MIGRATE=a npm run start:bundle
}
npm i sqlite3
make_migration "database.db" "sqlite"
[ -z "$FC_DB_POSTGRES" ] || (
npm i pg
make_migration "$FC_DB_POSTGRES" "postgres"
)
[ -z "$FC_DB_MARIADB" ] || (
npm i mysql2
make_migration "$FC_DB_MARIADB" "mariadb"
)
[ -f ".env.tmp" ] && mv .env.tmp .env
|