forked from andika/membership-be
Permission fix
This commit is contained in:
37
check_permissions.py
Normal file
37
check_permissions.py
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Check permissions table status
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
from sqlalchemy import create_engine, text
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
DATABASE_URL = os.getenv('DATABASE_URL')
|
||||
|
||||
engine = create_engine(DATABASE_URL)
|
||||
Session = sessionmaker(bind=engine)
|
||||
db = Session()
|
||||
|
||||
print("Checking permissions table...")
|
||||
print("=" * 80)
|
||||
|
||||
# Check if permissions table exists
|
||||
result = db.execute(text("SELECT COUNT(*) FROM permissions"))
|
||||
count = result.scalar()
|
||||
|
||||
print(f"Total permissions in database: {count}")
|
||||
|
||||
if count > 0:
|
||||
print("\nSample permissions:")
|
||||
result = db.execute(text("SELECT code, name, module FROM permissions LIMIT 10"))
|
||||
for perm in result.fetchall():
|
||||
print(f" - {perm[0]}: {perm[1]} (module: {perm[2]})")
|
||||
else:
|
||||
print("\n⚠️ WARNING: Permissions table is EMPTY!")
|
||||
print("\nThis will cause permission checks to fail.")
|
||||
print("\nAction needed: Run 'python3 seed_permissions.py'")
|
||||
|
||||
db.close()
|
||||
Reference in New Issue
Block a user