Skip to content

Commit

Permalink
Simplified script and removed all inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaliypopel committed Nov 29, 2024
1 parent b32536b commit 4f595d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4,251 deletions.
35 changes: 6 additions & 29 deletions apps/data_handler/migrate.sh
Original file line number Diff line number Diff line change
@@ -1,46 +1,23 @@
#!/bin/bash

if [ "$(basename $(dirname $(pwd)))/$(basename $(pwd))" != "derisk-research/apps" ]; then
echo "Current path to run this script should be in the \"~/derisk-research/apps\" directory"
echo "Current path to run this script should be in the \"derisk-research/apps\" directory"
exit 1
fi

echo "Loading \".env.dev\" file..."
source data_handler/.env.dev

if [[ "$DB_USER" == "postgres" ]]; then
read -p "Enter your DB username [required]: " NEW_DB_USER
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s/^DB_USER=.*$/DB_USER=$NEW_DB_USER/" data_handler/.env.dev
else
sed -i "s/^DB_USER=.*$/DB_USER=$NEW_DB_USER/" data_handler/.env.dev
fi
fi

if [[ "$DB_PASSWORD" == "password" ]]; then
read -p "Enter your DB password [required]: " NEW_DB_PASSWORD
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s/^DB_PASSWORD=.*$/DB_PASSWORD=$NEW_DB_PASSWORD/" data_handler/.env.dev
else
sed -i "s/^DB_PASSWORD=.*$/DB_PASSWORD=$NEW_DB_PASSWORD/" data_handler/.env.dev
fi
fi

echo "Running DB in Docker container..."
docker-compose -f ../devops/dev/docker-compose.db.yaml --env-file data_handler/.env.dev up -d --remove-orphans

echo "Installing Poetry globally..."
curl -sSL https://install.python-poetry.org | python3 -

echo "Installing all dependencies for \"data_handler\" with Poetry..."
cd data_handler
poetry install

echo "Activating environment..."
poetry shell
cd ..

echo "Applying latest existing migrations..."
alembic -c data_handler/alembic.ini upgrade head

read -p "Enter migration message: " migration

echo "Generating new \"$migration\" migration..."
alembic -c data_handler/alembic.ini revision --autogenerate -m "$migration"
echo "Generating new migration..."
alembic -c data_handler/alembic.ini revision --autogenerate -m "Migration"
Loading

0 comments on commit 4f595d3

Please sign in to comment.