diff --git a/app/RSpade/Commands/Database/Query_Command.php b/app/RSpade/Commands/Database/Query_Command.php index 2c12316bf..84c3ea6ec 100644 --- a/app/RSpade/Commands/Database/Query_Command.php +++ b/app/RSpade/Commands/Database/Query_Command.php @@ -46,6 +46,18 @@ class Query_Command extends Command // Determine query type $is_select = preg_match('/^\s*(SELECT|SHOW|EXPLAIN|DESCRIBE|DESC)\b/i', $query); $is_data_modification = preg_match('/^\s*(INSERT|UPDATE|DELETE|REPLACE|TRUNCATE)\b/i', $query); + + // Warn about querying _type_refs table directly + if (stripos($query, 'select') !== false && stripos($query, '_type_refs') !== false) { + $this->warn( + "[WARNING] Querying _type_refs table directly is discouraged.\n" . + " Type ref IDs are auto-generated and not predictable across environments.\n" . + " Use the Type_Ref_Registry API instead:\n" . + " \$id = Type_Ref_Registry::class_to_id('Model_Name');\n" . + " This applies especially to migrations - see rsx/resource/migrations/CLAUDE.md" + ); + $this->newLine(); + } // Check if this is a SELECT query that needs modification $needs_limit_injection = preg_match('/^\s*SELECT\b/i', $query) && preg_match('/\bFROM\b/i', $query);