Version Control for Databases - A web-based workbench with built-in version control capabilities for relational SQL databases.
This system provides a web-based workbench for relational SQL databases that allows users to run queries through a UI and view outputs, while also providing version control capabilities for database write operations. The system enables rollback to previous versions using a combination of command history, inverse operations, and mandatory snapshots.
- SQL Query Execution: Execute SQL queries via web UI with immediate results display
- Change Tracking: Track all database-modifying SQL commands (INSERT, UPDATE, DELETE, CREATE, ALTER, DROP)
- Version History: Maintain a versioned commit history of all database modifications
- Rollback Mechanism: Roll back database state to any previous version
- Snapshot System: Optimized rollback using mandatory snapshots at configurable intervals
- Schema Support: Support for schema-altering commands (DDL operations)
-
Web-based User Interface
- SQL command editor
- Query results display panel
- Commit history timeline viewer
- Rollback workflow interface
- Snapshot configuration screen
-
Backend Processing Service
- Query validation and execution
- Version management
- Inverse operation generation
-
Event Streaming Layer
- Command serialization
- Concurrency handling through event ordering
-
Snapshot Storage System
- Cloud-based object storage for snapshots
- Periodic snapshot creation
- Database: PostgreSQL (SQL-based relational database)
- Backend: Python
- Event Streaming: TBD
- Storage: Cloud object storage (S3 or equivalent)
- Frontend: Web-based UI
The system implements version control for databases through:
- Commits: Every successful database-modifying command is treated as a distinct commit
- Snapshots: Mandatory database state snapshots created at user-configurable intervals
- Inverse Operations (Anti-commands): For each write operation, an inverse operation is stored to enable rollback
- Event Ordering: All operations are strictly ordered through an event streaming mechanism
When rolling back to a previous version:
- System identifies the nearest snapshot before the target version
- Restores the database from that snapshot
- Replays inverse operations between the snapshot and target version
- If inverse operation fails, impact is limited to the interval between adjacent snapshots
- Default frequency: One snapshot per five commits
- Maximum frequency: One snapshot per commit
- Minimum frequency: One snapshot at system initialization
- User-configurable: Frequency can be adjusted based on needs
INSERT- Add new recordsUPDATE- Modify existing recordsDELETE- Remove recordsCREATE- Create database objectsALTER- Modify schemaDROP- Remove database objects
SELECTand other read-only queries can be executed but are not version controlled
- Python 3.x
- PostgreSQL database
- Cloud storage access (for snapshots)
# Clone the repository
git clone <repository-url>
# Install dependencies
pip install -r requirements.txt
# Configure database connection
# Edit config.yaml with your database credentialsEdit config.yaml to set:
- Database connection parameters
- Snapshot frequency
- Storage settings
- Event streaming configuration
- Access the web UI
- Enter SQL command in the editor
- Execute to see results
- View commit history for write operations
- Navigate to commit history timeline
- Select target version
- Review rollback plan
- Confirm and monitor progress
- Verify restored state with SELECT queries
| Element | Style | Example |
|---|---|---|
| Classes | PascalCase | DatabaseAdapter, RollbackManager |
| Methods | camelCase | executeWrite(), loadSnapshot() |
| Variables | camelCase | versionId, sqlCommand |
| Constants | UPPER_CASE | DEFAULT_SNAPSHOT_FREQ |
| Database Tables | lower_case | commit_events, snapshots |
- Use
TODOandFIXMEkeywords for planned work and issues - Include author name/identifier for non-trivial comments
- SQL-based relational database
- Backend service environment
- Web browser (for UI access)
- Networked deployment environment
- Only SQL-based databases supported
- Only data-modifying queries are tracked
- Snapshots are mandatory
- Event streaming required for concurrency
- Track dependencies between tables
- Account for foreign key relationships in anti-commands
- Coordinated rollback across related tables
- SRS Document: See docs/srs.pdf for complete software requirements specification
- User Guide: Instructions for SQL query submission, output interpretation, and rollback operations
- Admin Guide: System maintenance, availability, and storage infrastructure documentation
- Inline Help: Version control terminology and configuration guidance
Current Version: Single table tracking within a database Future Versions: Will expand to support tracking multiple tables within a database
- Version: Logical state of the database after applying a set of commands
- Commit: A successful database-modifying operation that advances the version state
- Snapshot: Stored representation of complete database state at a specific version
- Anti-command: Inverse operation used to reverse a commit during rollback
- Event Stream: Ordered sequence of database modifications ensuring consistency
[License information to be added]
For detailed requirements and system specifications, please refer to the Software Requirements Specification.