mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 05:30:46 +08:00
feat: initialize netx ops tool repository
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>
This commit is contained in:
commit
f49c0b5bad
56 changed files with 6974 additions and 0 deletions
35
scripts/reset_db.py
Normal file
35
scripts/reset_db.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
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()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue