summaryrefslogtreecommitdiff
path: root/makima/sh
diff options
context:
space:
mode:
Diffstat (limited to 'makima/sh')
-rwxr-xr-x[-rw-r--r--]makima/sh/download-models.sh0
-rwxr-xr-xmakima/sh/run-migrations.sh11
-rwxr-xr-xmakima/sh/setup-db.sh22
-rwxr-xr-xmakima/sh/start-postgres.sh32
4 files changed, 65 insertions, 0 deletions
diff --git a/makima/sh/download-models.sh b/makima/sh/download-models.sh
index 0381e15..0381e15 100644..100755
--- a/makima/sh/download-models.sh
+++ b/makima/sh/download-models.sh
diff --git a/makima/sh/run-migrations.sh b/makima/sh/run-migrations.sh
new file mode 100755
index 0000000..d34d6b1
--- /dev/null
+++ b/makima/sh/run-migrations.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+# Run sqlx migrations
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+MAKIMA_DIR="$(dirname "${SCRIPT_DIR}")"
+
+POSTGRES_CONNECTION_URI="${POSTGRES_CONNECTION_URI:-postgres://makima:makima_dev@localhost:5432/makima}"
+
+echo "Running migrations from ${MAKIMA_DIR}/migrations..."
+sqlx migrate run --source "${MAKIMA_DIR}/migrations" --database-url "${POSTGRES_CONNECTION_URI}"
+echo "Migrations complete!"
diff --git a/makima/sh/setup-db.sh b/makima/sh/setup-db.sh
new file mode 100755
index 0000000..95e35ac
--- /dev/null
+++ b/makima/sh/setup-db.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+# Combined database setup script
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+
+echo "=== Setting up Makima Database ==="
+echo ""
+
+# Start PostgreSQL
+echo "Step 1: Starting PostgreSQL..."
+bash "${SCRIPT_DIR}/start-postgres.sh"
+echo ""
+
+# Wait a moment for full initialization
+sleep 2
+
+# Run migrations
+echo "Step 2: Running migrations..."
+bash "${SCRIPT_DIR}/run-migrations.sh"
+echo ""
+
+echo "=== Database setup complete! ==="
diff --git a/makima/sh/start-postgres.sh b/makima/sh/start-postgres.sh
new file mode 100755
index 0000000..203b178
--- /dev/null
+++ b/makima/sh/start-postgres.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+# Start PostgreSQL via Docker for local development
+
+CONTAINER_NAME="makima-postgres"
+POSTGRES_USER="makima"
+POSTGRES_PASSWORD="makima_dev"
+POSTGRES_DB="makima"
+POSTGRES_PORT="5432"
+
+# Check if container already exists
+if docker ps -a --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
+ echo "Container ${CONTAINER_NAME} exists. Starting..."
+ docker start ${CONTAINER_NAME}
+else
+ echo "Creating new PostgreSQL container..."
+ docker run -d \
+ --name ${CONTAINER_NAME} \
+ -e POSTGRES_USER=${POSTGRES_USER} \
+ -e POSTGRES_PASSWORD=${POSTGRES_PASSWORD} \
+ -e POSTGRES_DB=${POSTGRES_DB} \
+ -p ${POSTGRES_PORT}:5432 \
+ -v makima_postgres_data:/var/lib/postgresql/data \
+ postgres:16-alpine
+fi
+
+echo "Waiting for PostgreSQL to be ready..."
+until docker exec ${CONTAINER_NAME} pg_isready -U ${POSTGRES_USER} 2>/dev/null; do
+ sleep 1
+done
+
+echo "PostgreSQL is ready!"
+echo "Connection URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:${POSTGRES_PORT}/${POSTGRES_DB}"