mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 06:40:45 +08:00
Set up netx as a standalone git-managed project with isolated Python dependencies, alarm ingestion/query APIs, oclaw bridge integration, and ops-focused UI enhancements including history and raw field access. Co-authored-by: Cursor <cursoragent@cursor.com>
35 lines
880 B
Python
35 lines
880 B
Python
from __future__ import annotations
|
|
|
|
"""
|
|
Dangerous: drop all netx tables and recreate schema.
|
|
|
|
Usage (PowerShell):
|
|
Set-Location D:\\project\\chatgpt\\netx
|
|
python scripts\\reset_db.py
|
|
|
|
It uses NETX_DATABASE_URL (via netx_api.config settings).
|
|
"""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Ensure `import netx_api` works when executed as a script.
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
if str(ROOT) not in sys.path:
|
|
sys.path.insert(0, str(ROOT))
|
|
|
|
import netx_api.models # noqa: F401,E402 # ensure SQLAlchemy models are registered to Base.metadata
|
|
from netx_api.db import Base, engine # noqa: E402
|
|
|
|
|
|
def main() -> None:
|
|
# Drop all tables first (data loss).
|
|
Base.metadata.drop_all(bind=engine)
|
|
# Recreate with current models.
|
|
Base.metadata.create_all(bind=engine)
|
|
print("ok: dropped and recreated all tables")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|