-- Complete fix for Directus collections -- First, remove any existing entries DELETE FROM directus_collections WHERE collection IN ('moderation_flags', 'user_status_history'); -- Add the collections with proper configuration INSERT INTO directus_collections (collection, icon, note, hidden, singleton) VALUES ('moderation_flags', 'flag', 'AI-powered content moderation flags', false, false), ('user_status_history', 'history', 'User status change history for audit trail', false, false); -- Add field configurations for moderation_flags INSERT INTO directus_fields (collection, field, data_type, interface, options) VALUES ('moderation_flags', 'id', 'uuid', 'input', NULL), ('moderation_flags', 'post_id', 'uuid', 'relationship', '{"collection":"posts"}'), ('moderation_flags', 'comment_id', 'uuid', 'relationship', '{"collection":"comments"}'), ('moderation_flags', 'flag_reason', 'string', 'dropdown', '{"choices":"hate,greed,delusion,spam,other"}'), ('moderation_flags', 'scores', 'json', 'json', NULL), ('moderation_flags', 'status', 'string', 'dropdown', '{"choices":"pending,approved,rejected,escalated"}'), ('moderation_flags', 'reviewed_by', 'uuid', 'relationship', '{"collection":"directus_users"}'), ('moderation_flags', 'reviewed_at', 'timestamp', 'datetime', NULL), ('moderation_flags', 'created_at', 'timestamp', 'datetime', NULL), ('moderation_flags', 'updated_at', 'timestamp', 'datetime', NULL); -- Add field configurations for user_status_history INSERT INTO directus_fields (collection, field, data_type, interface, options) VALUES ('user_status_history', 'id', 'uuid', 'input', NULL), ('user_status_history', 'user_id', 'uuid', 'relationship', '{"collection":"users"}'), ('user_status_history', 'old_status', 'string', 'dropdown', '{"choices":"active,suspended,banned"}'), ('user_status_history', 'new_status', 'string', 'dropdown', '{"choices":"active,suspended,banned"}'), ('user_status_history', 'reason', 'text', 'input', NULL), ('user_status_history', 'changed_by', 'uuid', 'relationship', '{"collection":"directus_users"}'), ('user_status_history', 'created_at', 'timestamp', 'datetime', NULL); -- Verify the setup SELECT 'Collections configured:' as info; SELECT collection, icon, note FROM directus_collections WHERE collection IN ('moderation_flags', 'user_status_history'); SELECT 'Fields configured for moderation_flags:' as info; SELECT field, data_type, interface FROM directus_fields WHERE collection = 'moderation_flags';