Spaces:
Paused
Paused
File size: 1,315 Bytes
5eb4857 4405ca9 5eb4857 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 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())
|