Files
rspade_system/app/RSpade/SchemaQuality/Rules/SessionIdForeignKeyRule.php
root 77b4d10af8 Refactor filename naming system and apply convention-based renames
Standardize settings file naming and relocate documentation files
Fix code quality violations from rsx:check
Reorganize user_management directory into logical subdirectories
Move Quill Bundle to core and align with Tom Select pattern
Simplify Site Settings page to focus on core site information
Complete Phase 5: Multi-tenant authentication with login flow and site selection
Add route query parameter rule and synchronize filename validation logic
Fix critical bug in UpdateNpmCommand causing missing JavaScript stubs
Implement filename convention rule and resolve VS Code auto-rename conflict
Implement js-sanitizer RPC server to eliminate 900+ Node.js process spawns
Implement RPC server architecture for JavaScript parsing
WIP: Add RPC server infrastructure for JS parsing (partial implementation)
Update jqhtml terminology from destroy to stop, fix datagrid DOM preservation
Add JQHTML-CLASS-01 rule and fix redundant class names
Improve code quality rules and resolve violations
Remove legacy fatal error format in favor of unified 'fatal' error type
Filter internal keys from window.rsxapp output
Update button styling and comprehensive form/modal documentation
Add conditional fly-in animation for modals
Fix non-deterministic bundle compilation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-13 19:10:02 +00:00

56 lines
2.2 KiB
PHP
Executable File

<?php
namespace App\RSpade\SchemaQuality\Rules;
class SessionIdForeignKeyRule extends Schema_Rule_Abstract
{
public function get_id(): string
{
return 'SCHEMA-FK-01';
}
public function get_name(): string
{
return 'Session ID Foreign Key Rule';
}
public function get_description(): string
{
return 'Ensures session_id columns are nullable. Foreign key constraints to sessions table are NOT enforced - session IDs are ephemeral tracking identifiers that should not have referential integrity constraints.';
}
public function check(array $schema): void
{
foreach ($schema['tables'] as $table_name => $table_info) {
if ($this->is_excluded_table($table_name)) {
continue;
}
// Check each column for session_id
foreach ($table_info['columns'] as $column) {
if ($column['name'] === 'session_id') {
// Check if nullable - session_id must always be nullable
if ($column['nullable'] !== 'YES') {
$this->add_violation(
$table_name,
'session_id',
'Column session_id must be nullable (ephemeral tracking identifier)',
'ALTER TABLE ' . $table_name . ' MODIFY session_id VARCHAR(255) NULL'
);
}
// NOTE: We do NOT enforce foreign key constraints for session_id columns.
// Session IDs are ephemeral tracking identifiers used for:
// - Temporary file upload tracking (file_attachments)
// - Short-term security validation
// - Session-scoped data that doesn't need referential integrity
//
// Adding FK constraints would:
// - Prevent cleanup of old sessions (cascade deletes unwanted)
// - Create unnecessary coupling between ephemeral and persistent data
// - Violate the principle that sessions are temporary, data is permanent
}
}
}
}
}