-- Rollback modules and permissions update

-- Remove the new structured permissions
DELETE FROM permissions WHERE code LIKE '%_READ' OR code LIKE '%_WRITE' OR code LIKE '%_CREATE' OR code LIKE '%_DELETE';

-- Drop indexes
DROP INDEX IF EXISTS idx_permissions_module_id;

-- Remove columns from permissions table
ALTER TABLE permissions 
    DROP COLUMN IF EXISTS module_id,
    DROP COLUMN IF EXISTS action;

-- Drop modules table
DROP TABLE IF EXISTS modules CASCADE;