summaryrefslogtreecommitdiff
path: root/ar/.local
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2026-02-25 08:30:46 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2026-02-25 08:30:46 +0900
commit72a1195c7a2d1466f9d76e8da56a76374cc12974 (patch)
tree1e31892939231ca802a9114536cd7c007e0321c2 /ar/.local
parent64c88ef21ac3369e4e4fad179dfd641722a1f349 (diff)
modified git/ignore, modified bin/ddb
Diffstat (limited to 'ar/.local')
-rwxr-xr-xar/.local/bin/ddb42
1 files changed, 40 insertions, 2 deletions
diff --git a/ar/.local/bin/ddb b/ar/.local/bin/ddb
index 0ecbf88..ae2ef8d 100755
--- a/ar/.local/bin/ddb
+++ b/ar/.local/bin/ddb
@@ -90,6 +90,7 @@ find_drizzle_migrations() {
# Parse command line arguments
MIGRATE_MODE=0
+GENERATE_MODE=0
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "Usage: $(basename "$0") [OPTIONS]"
@@ -97,8 +98,10 @@ if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "Interactive script to query Docker database containers"
echo ""
echo "Options:"
- echo " -h, --help Show this help message"
- echo " -m, --migrate Run drizzle migration SQL file"
+ echo " -h, --help Show this help message"
+ echo " -g, --generate Run drizzle-kit generate to create migration files"
+ echo " -m, --migrate Run drizzle migration SQL file"
+ echo " -gm, --generate-migrate Run drizzle-kit generate then immediately migrate"
echo ""
echo "Supported databases:"
echo " - PostgreSQL"
@@ -106,8 +109,43 @@ if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo " - MongoDB"
echo " - Redis"
exit 0
+elif [ "$1" = "-g" ] || [ "$1" = "--generate" ]; then
+ GENERATE_MODE=1
elif [ "$1" = "-m" ] || [ "$1" = "--migrate" ]; then
MIGRATE_MODE=1
+elif [ "$1" = "-gm" ] || [ "$1" = "--generate-migrate" ]; then
+ GENERATE_MODE=1
+ MIGRATE_MODE=1
+fi
+
+# Handle generate step (runs before container selection)
+if [ "$GENERATE_MODE" = 1 ]; then
+ git_root=$(git rev-parse --show-toplevel 2>/dev/null)
+ if [ -n "$git_root" ]; then
+ project_dir="$git_root"
+ echo "[INFO] Found git root: $git_root"
+ else
+ project_dir="$(pwd)"
+ echo "[INFO] Using current directory: $project_dir"
+ fi
+
+ echo "[INFO] Running drizzle-kit generate..."
+ echo ""
+
+ if (cd "$project_dir" && npx drizzle-kit generate); then
+ echo ""
+ echo "[SUCCESS] Migration files generated successfully"
+ else
+ echo ""
+ echo "[ERROR] drizzle-kit generate failed" >&2
+ exit 1
+ fi
+
+ if [ "$MIGRATE_MODE" = 0 ]; then
+ exit 0
+ fi
+
+ echo ""
fi
# Get database containers and save to temp file