35 lines
1.1 KiB
Bash
Executable File
35 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
# 1. Pull latest code
|
|
echo "Pulling latest code..."
|
|
cd /opt/microdao-daarion
|
|
git pull origin main
|
|
|
|
# 2. Check if database exists, create if not
|
|
echo "Checking database..."
|
|
if docker exec dagi-postgres psql -U postgres -lqt | cut -d \| -f 1 | grep -qw daarion_memory; then
|
|
echo "Database daarion_memory exists."
|
|
else
|
|
echo "Database daarion_memory does not exist. Creating..."
|
|
docker exec dagi-postgres psql -U postgres -c "CREATE DATABASE daarion_memory;"
|
|
fi
|
|
|
|
# 3. Setup extensions
|
|
echo "Enabling extensions..."
|
|
docker exec dagi-postgres psql -U postgres -d daarion_memory -c 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp";'
|
|
|
|
# 4. Apply all migrations in order
|
|
echo "Applying migrations..."
|
|
for f in migrations/*.sql; do
|
|
echo "Applying $f..."
|
|
docker exec -i dagi-postgres psql -U postgres -d daarion_memory < "$f" || echo "Warning: Migration $f had errors, continuing..."
|
|
done
|
|
|
|
# 5. Rebuild and restart city-service
|
|
echo "Restarting city-service..."
|
|
docker compose up -d --build city-service
|
|
|
|
echo "Deployment and DB restoration complete!"
|
|
|