diff --git a/migrate.bat b/migrate.bat new file mode 100644 index 0000000..c38d7fb --- /dev/null +++ b/migrate.bat @@ -0,0 +1,23 @@ +@echo off +setlocal + +if "%~1"=="" ( + echo Usage: migrate.bat path\to\migration.sql + exit /b 1 +) + +set SQL_FILE=%~1 + +if not exist "%SQL_FILE%" ( + echo Error: File "%SQL_FILE%" does not exist. + exit /b 1 +) + +echo Running %SQL_FILE% against pragativeer_db... +docker exec -i pragativeer_db psql -U pragativeer_admin -d pragativeer_prod < "%SQL_FILE%" + +if %ERRORLEVEL% equ 0 ( + echo Migration applied successfully! +) else ( + echo Migration failed! +) diff --git a/migrate.sh b/migrate.sh new file mode 100644 index 0000000..b2471e2 --- /dev/null +++ b/migrate.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +if [ -z "$1" ]; then + echo "Usage: ./migrate.sh path/to/migration.sql" + exit 1 +fi + +SQL_FILE=$1 + +if [ ! -f "$SQL_FILE" ]; then + echo "Error: File $SQL_FILE does not exist." + exit 1 +fi + +echo "Running $SQL_FILE against pragativeer_db..." +docker exec -i pragativeer_db psql -U pragativeer_admin -d pragativeer_prod < "$SQL_FILE" + +if [ $? -eq 0 ]; then + echo "Migration applied successfully!" +else + echo "Migration failed!" +fi diff --git a/migrations/001_example.sql b/migrations/001_example.sql new file mode 100644 index 0000000..27bce96 --- /dev/null +++ b/migrations/001_example.sql @@ -0,0 +1,7 @@ +-- Example Migration File +-- You can write raw SQL here to fix your schema mismatches +-- For example, if you added a new column in models.py, you would add it here: + +-- ALTER TABLE "user" ADD COLUMN IF NOT EXISTS "trial_end" TIMESTAMP WITHOUT TIME ZONE; + +-- Then run: ./migrate.sh migrations/001_example.sql