summaryrefslogtreecommitdiff
path: root/doc/developer-utils
diff options
context:
space:
mode:
Diffstat (limited to 'doc/developer-utils')
-rwxr-xr-xdoc/developer-utils/create-alembic-migration.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/doc/developer-utils/create-alembic-migration.sh b/doc/developer-utils/create-alembic-migration.sh
new file mode 100755
index 0000000..1e884a3
--- /dev/null
+++ b/doc/developer-utils/create-alembic-migration.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+# Helper script to create an alembic migration file via Docker
+
+if [ $# -lt 1 ]; then
+ echo "Need to pass a name for your migration file" > /dev/stderr
+ exit 1
+fi
+
+# Create a dummy container
+WORKDIR="$(git rev-parse --show-toplevel)/server"
+IMAGE=$(docker build -q "${WORKDIR}")
+CONTAINER=$(docker run -d ${IMAGE} tail -f /dev/null)
+
+# Create the migration script
+docker exec -i \
+ -e PYTHONPATH='/opt/app' \
+ -e POSTGRES_HOST='x' \
+ -e POSTGRES_USER='x' \
+ -e POSTGRES_PASSWORD='x' \
+ ${CONTAINER} alembic revision -m "$1"
+
+# Copy the file over from the container
+docker cp ${CONTAINER}:/opt/app/szurubooru/migrations/versions/ \
+ "${WORKDIR}/szurubooru/migrations/"
+
+# Destroy the dummy container
+docker rm -f ${CONTAINER} > /dev/null