SPAR
SQL Governance Portal
Secure, Controlled Database Access for Enterprise Teams
Proof of Concept
James Hall & Co Ltd
•
Presented by Adam Entwistle
•
2026
Current challenges with database access and script execution
Managing database access across teams presents several critical challenges that impact security, efficiency, and compliance.
Without proper governance, database access becomes a security risk and operational bottleneck.
Laravel 12 + Livewire + Blade with PostgreSQL and AI integration
Modern tech stack built for scalability, security, and developer productivity.
5-tier permission hierarchy for granular access management
The portal implements a comprehensive 5-tier RBAC system that ensures users only access scripts appropriate to their role and expertise level.
enum UserRole: string
{
case FIRST_LINE = 'first_line';
case SECOND_LINE = 'second_line';
case RETAIL_DEV = 'retail_dev';
case INFRASTRUCTURE = 'infrastructure';
case ADMIN = 'admin';
public function hierarchy(): int
{
return match ($this) {
self::FIRST_LINE => 1,
self::SECOND_LINE => 2,
self::RETAIL_DEV => 3,
self::INFRASTRUCTURE => 4,
self::ADMIN => 5,
};
}
public function hasPermission(UserRole $required): bool
{
return $this->hierarchy() >= $required->hierarchy();
}
}
Each role has a hierarchy level. Users can only access scripts requiring their level or below.
Granular permissions ensure the right people have the right access at the right time.
Protected variable injection prevents SQL injection attacks
Users define variables in scripts using placeholders. The system validates, sanitises, and safely injects values at runtime.
public function sanitiseValue(string $value, string $type): string
{
return match ($type) {
'int', 'integer' => $this->sanitiseInteger($value),
'decimal', 'float' => $this->sanitiseDecimal($value),
'date' => $this->sanitiseDate($value),
default => $this->sanitiseString($value),
};
}
private function sanitiseString(string $value): string
{
// Escape single quotes by doubling them
$cleaned = str_replace("'", "''", $value);
return "'{$cleaned}'";
}
Zero SQL injection risk - all variables are validated and parameterised.
Automatic rollback protection for high-risk operations
High-risk scripts (UPDATE, DELETE, INSERT) are automatically wrapped in transactions with rollback capability.
private const TRANSACTION_HEADER = <<<'SQL'
-- HIGH RISK SCRIPT - Review carefully
BEGIN TRANSACTION;
SQL;
private const TRANSACTION_FOOTER = <<<'SQL'
-- IMPORTANT: Review results before committing!
-- Uncomment COMMIT to apply, or ROLLBACK to abort
-- COMMIT;
ROLLBACK;
SQL;
public function applyTransactionWrapper(
string $sql, RiskLevel $riskLevel
): array {
if (!$riskLevel->requiresTransactionWrapper()) {
return [$sql, false];
}
return [self::TRANSACTION_HEADER . $sql . self::TRANSACTION_FOOTER, true];
}
Test first, commit only when certain - prevents accidental data modification.
Manager approval required for critical operations
Critical scripts require manager approval before execution, creating a safety checkpoint for high-impact operations.
Human oversight for critical operations - automated safety with manual verification.
Every action logged for compliance and security
All user actions, script executions, and system events are logged with full context for compliance and forensic analysis.
Full traceability meets compliance requirements and enables forensic investigation.
Semantic search using Google Gemini embeddings and pgvector
Find scripts by describing what you need in natural language - no need to remember exact names or keywords.
// Generate embedding for search query
$queryEmbedding = $this->embeddingService->generateQueryEmbedding($query);
// pgvector cosine similarity search
$sql = "
SELECT id, name, description,
1 - (embedding <=> :embedding::vector) as similarity
FROM scripts
WHERE state = 'checked_in'
AND embedding IS NOT NULL
ORDER BY embedding <=> :embedding2::vector
LIMIT :limit
";
The <=> operator calculates cosine distance. Lower distance = higher similarity.
Find what you need by describing the problem, not memorising script names.
Notifications and approvals directly in Teams
Receive notifications and approve requests without leaving Teams - reducing context switching and accelerating workflows.
Work where you already are - approvals and notifications in your existing workflow.
Full version control with diffs and rollback
Complete version history for all scripts with visual diffs and one-click rollback to any previous version.
Never lose work - complete version control for all scripts with easy rollback.
Experience the portal in action
Filter by category, risk level, permissions
Choose script, fill in variables
Review generated SQL, execute safely
View output, download reports
See execution history and details
Find scripts using natural language
See the complete workflow from script discovery to execution and audit.
RBAC, sanitisation, transaction safety, and approval workflows ensure database operations are secure by default.
Comprehensive audit trails and approval workflows meet regulatory requirements and enable forensic analysis.
AI-powered search, version control, and Teams integration make the portal intuitive and efficient.
Built with Laravel 12, Livewire, and AI integration - ready for future enhancements.