Alembic experiments
This commit is contained in:
47
reset_database.sh
Normal file
47
reset_database.sh
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
# Reset database and initialize Alembic from scratch
|
||||
|
||||
echo "=== Database Reset Script ==="
|
||||
echo "This will drop all tables and reinitialize with Alembic"
|
||||
echo ""
|
||||
read -p "Are you sure? (type 'yes' to continue): " confirm
|
||||
|
||||
if [ "$confirm" != "yes" ]; then
|
||||
echo "Aborted."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Step 1: Dropping all tables in the database..."
|
||||
echo "Connect to your database and run:"
|
||||
echo ""
|
||||
echo " -- For PostgreSQL:"
|
||||
echo " DROP SCHEMA public CASCADE;"
|
||||
echo " CREATE SCHEMA public;"
|
||||
echo " GRANT ALL ON SCHEMA public TO <your_user>;"
|
||||
echo " GRANT ALL ON SCHEMA public TO public;"
|
||||
echo ""
|
||||
echo " -- Or if using a custom schema (e.g., alpinebits):"
|
||||
echo " DROP SCHEMA alpinebits CASCADE;"
|
||||
echo " CREATE SCHEMA alpinebits;"
|
||||
echo ""
|
||||
echo "Press Enter after you've run the SQL commands..."
|
||||
read
|
||||
|
||||
echo ""
|
||||
echo "Step 2: Running Alembic migrations..."
|
||||
uv run alembic upgrade head
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo ""
|
||||
echo "=== Success! ==="
|
||||
echo "Database has been reset and migrations applied."
|
||||
echo ""
|
||||
echo "Current migration status:"
|
||||
uv run alembic current
|
||||
else
|
||||
echo ""
|
||||
echo "=== Error ==="
|
||||
echo "Migration failed. Check the error messages above."
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user