summary refs log tree commit diff
path: root/scripts/db_migrations.sh
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-15 11:13:21 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-15 11:13:21 +0200
commit1a94fb1208bf0e4c669cad16aff5f57dc0bf7a3c (patch)
tree1035116ddbaacc5fcc5ae250a6592eb88f78f75c /scripts/db_migrations.sh
parentDo the funny thing (make user->invite cascade delet) (diff)
parentchange dev panel path, we missed this one... (diff)
downloadserver-1a94fb1208bf0e4c669cad16aff5f57dc0bf7a3c.tar.xz
Merge branch 'dev/restructure' into staging
Diffstat (limited to 'scripts/db_migrations.sh')
-rwxr-xr-xscripts/db_migrations.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/scripts/db_migrations.sh b/scripts/db_migrations.sh
new file mode 100755

index 00000000..9ec8230a --- /dev/null +++ b/scripts/db_migrations.sh
@@ -0,0 +1,41 @@ +#!/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 2>/dev/null + source .env.tmp 2>/dev/null +) +npm run build clean logerrors pretty-errors + +make_migration() { + echo "Creating migrations for $2" + mkdir "src/util/migrations/$2" 2>/dev/null +# 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 "src/util/migrations/$2/$FILENAME" -d src/util/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 2>/dev/null +