Spaces:
Sleeping
Sleeping
Upload scripts/create_billing_tables.py with huggingface_hub
Browse files
scripts/create_billing_tables.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Create billing database tables.
|
| 3 |
+
Run this script to initialize the billing database.
|
| 4 |
+
"""
|
| 5 |
+
import sys
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
|
| 8 |
+
# Add parent directory to path
|
| 9 |
+
sys.path.insert(0, str(Path(__file__).parent.parent))
|
| 10 |
+
|
| 11 |
+
from app.db.database import init_db, engine
|
| 12 |
+
from app.db.models import Base
|
| 13 |
+
|
| 14 |
+
def main():
|
| 15 |
+
"""Create all billing tables."""
|
| 16 |
+
print("Creating billing database tables...")
|
| 17 |
+
try:
|
| 18 |
+
# Create all tables
|
| 19 |
+
Base.metadata.create_all(bind=engine)
|
| 20 |
+
print("✅ Billing tables created successfully!")
|
| 21 |
+
print("\nTables created:")
|
| 22 |
+
print(" - tenants")
|
| 23 |
+
print(" - tenant_plans")
|
| 24 |
+
print(" - usage_events")
|
| 25 |
+
print(" - usage_daily")
|
| 26 |
+
print(" - usage_monthly")
|
| 27 |
+
except Exception as e:
|
| 28 |
+
print(f"❌ Error creating tables: {e}")
|
| 29 |
+
sys.exit(1)
|
| 30 |
+
|
| 31 |
+
if __name__ == "__main__":
|
| 32 |
+
main()
|
| 33 |
+
|