Spaces:
Paused
Paused
Download scripts/cloud_wipe.py from 3SCError404/nexus: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/spaces/3SCError404/nexus/resolve/main/scripts/cloud_wipe.py
- Command line
-
hf download hf://spaces/3SCError404/nexus/scripts/cloud_wipe.py
-
curl -L -o cloud_wipe.py https://huggingface.co/spaces/3SCError404/nexus/resolve/main/scripts/cloud_wipe.py
1.32 kB
| import asyncio | |
| import sys | |
| import os | |
| from sqlalchemy import text | |
| # Add project root to path | |
| sys.path.append(os.getcwd()) | |
| from core.database import engine | |
| async def cloud_wipe(): | |
| """ | |
| SAFELY wipes the public schema of the database one command at a time. | |
| """ | |
| print("\n--- NEXUS: CLOUD DATABASE WIPE (RESTORING) ---") | |
| print(f"Target: {engine.url.render_as_string(hide_password=True)}") | |
| print("WARNING: This will delete ALL tables and custom types in the public schema.") | |
| confirm = input("Are you sure you want to proceed? (y/N): ") | |
| if confirm.lower() != 'y': | |
| print("Wipe cancelled.") | |
| return | |
| async with engine.begin() as conn: | |
| print("Dropping schema 'public'...") | |
| # We run these separately to avoid 'cannot insert multiple commands' error | |
| await conn.execute(text("DROP SCHEMA IF EXISTS public CASCADE")) | |
| print("Re-creating schema 'public'...") | |
| await conn.execute(text("CREATE SCHEMA public")) | |
| print("Restoring permissions...") | |
| await conn.execute(text("GRANT ALL ON SCHEMA public TO postgres")) | |
| await conn.execute(text("GRANT ALL ON SCHEMA public TO public")) | |
| print("✅ Public schema WIPED and RESET.") | |
| if __name__ == "__main__": | |
| asyncio.run(cloud_wipe()) | |