#!/usr/bin/env python
"""Create utils_notification table using pure pymysql without Django"""
import pymysql

# Database connection
conn = pymysql.connect(
    host='localhost',
    user='root',
    password='password',
    database='xygbfpsg_graz',
    charset='utf8mb4'
)

try:
    with conn.cursor() as cursor:
        # Create notification table
        cursor.execute("""
            CREATE TABLE IF NOT EXISTS utils_notification (
                id CHAR(32) NOT NULL PRIMARY KEY,
                notification_type VARCHAR(50) NOT NULL,
                title VARCHAR(200) NOT NULL,
                message LONGTEXT NOT NULL,
                priority VARCHAR(20) NOT NULL,
                created_at DATETIME(6) NOT NULL,
                read_at DATETIME(6) NULL,
                action_url VARCHAR(200) NULL,
                expires_at DATETIME(6) NULL,
                icon VARCHAR(50) NOT NULL,
                user_id CHAR(32) NULL,
                FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
            )
        """)
        conn.commit()
        print("✓ utils_notification table created successfully!")
        
except Exception as e:
    print(f"❌ Error: {str(e)}")
    conn.rollback()
finally:
    conn.close()
