Skip to content

Add maintenance tools (VACUUM, ANALYZE, OPTIMIZE, REINDEX)#640

Merged
datlechin merged 4 commits intomainfrom
feat/maintenance-tools
Apr 8, 2026
Merged

Add maintenance tools (VACUUM, ANALYZE, OPTIMIZE, REINDEX)#640
datlechin merged 4 commits intomainfrom
feat/maintenance-tools

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

Summary

Adds database maintenance operations accessible from the sidebar table context menu. Right-click a table > Maintenance submenu shows database-specific operations.

Database Operations
PostgreSQL VACUUM, ANALYZE, REINDEX, CLUSTER
MySQL/MariaDB OPTIMIZE TABLE, ANALYZE TABLE, CHECK TABLE, REPAIR TABLE
SQLite VACUUM, ANALYZE, REINDEX, Integrity Check

Each operation shows a confirmation sheet with:

  • Operation name and target table
  • Database-specific options (e.g. FULL, ANALYZE, VERBOSE for PostgreSQL VACUUM; check mode for MySQL CHECK TABLE)
  • Live SQL preview
  • Cancel / Execute buttons

Results shown via success/error alert after execution.

Architecture

Follows the existing truncate/drop pattern:

  1. Plugin protocol: supportedMaintenanceOperations() + maintenanceStatements() with default nil implementations
  2. Built-in plugin implementations for PostgreSQL, MySQL, SQLite
  3. Context menu submenu (only shown when driver supports maintenance)
  4. MaintenanceSheet confirmation dialog
  5. Coordinator executes SQL directly via driver.execute(query:) (no query tab needed)

Databases without maintenance support (Redis, MongoDB, etc.) show no submenu.

Files

  • New: TablePro/Views/Sidebar/MaintenanceSheet.swift
  • Protocol: PluginDatabaseDriver.swift, DatabaseDriver.swift, PluginDriverAdapter.swift
  • Plugins: PostgreSQLPluginDriver.swift, MySQLPluginDriver.swift, SQLitePlugin.swift
  • UI: SidebarContextMenu.swift, MainContentView.swift, MainContentCoordinator.swift, MainContentCoordinator+SidebarActions.swift

Test plan

  • PostgreSQL: right-click table > Maintenance > VACUUM > toggle FULL/ANALYZE/VERBOSE > verify SQL preview > Execute
  • PostgreSQL: ANALYZE, REINDEX, CLUSTER on a table
  • MySQL: OPTIMIZE TABLE, ANALYZE TABLE, CHECK TABLE (with mode picker), REPAIR TABLE
  • SQLite: VACUUM, ANALYZE, REINDEX, Integrity Check
  • Redis/MongoDB: verify no Maintenance submenu appears
  • Read-only safe mode: verify maintenance operations are blocked
  • Error handling: verify error alert on failure (e.g., CLUSTER without index)

@datlechin datlechin merged commit 5ad338a into main Apr 8, 2026
2 checks passed
@datlechin datlechin deleted the feat/maintenance-tools branch April 8, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant