-- Fix the custom user_permissions table that's causing the permission error
-- This is different from Django's built-in users_user_permissions table

-- Check current structure
DESCRIBE user_permissions;

-- Fix the permission_id column by adding a default value
-- This will resolve the "Field 'permission_id' doesn't have a default value" error
ALTER TABLE user_permissions MODIFY COLUMN permission_id INT NOT NULL DEFAULT 0;

-- Verify the fix
DESCRIBE user_permissions;

-- Test insert (optional - replace with actual values from your database)
-- INSERT INTO user_permissions (user_id, module, action, is_allowed, permission_id) 
-- VALUES ('your-user-id-here', 'test', 'view', 1, 0);

-- Clean up test record
-- DELETE FROM user_permissions WHERE user_id = 'your-user-id-here' AND module = 'test';
