half_orm development Framework.
Project description
half-orm-dev
WARNING! half-orm-dev is in alpha development phase!
Please report any issues at GitHub Issues
Git-centric patch management and database versioning for half-orm projects
Modern development workflow for PostgreSQL databases with automatic code generation, semantic versioning, and production-ready deployment system.
๐ What is half-orm-dev?
half-orm-dev provides a complete development lifecycle for database-driven applications:
- Git-centric workflow: Patches stored in Git branches with semantic versioning
- Test-Driven Development: Automatic validation - tests run before integration, patches blocked if tests fail
- Code generation: Python classes auto-generated from schema changes
- Safe deployments: Sequential releases with automatic backups and validation
- Team collaboration: Distributed locks, branch management, conflict prevention
- Cloud-friendly: No superuser privileges required (works on AWS RDS, Azure, GCP)
Perfect for teams managing evolving PostgreSQL schemas with Python applications.
โจ Key Features
๐งช Systematic Test Validation (Core Safety Feature)
Tests run automatically before patch integration and block merges if they fail.
# When you merge a patch, half-orm-dev:
git checkout ho-patch/123-feature
half_orm dev patch merge
# Behind the scenes:
# 1. Creates temporary validation branch
# 2. Merges ALL patches in release context
# 3. Runs pytest automatically
# 4. โ
If PASS โ merges into release, status โ "staged"
# 5. โ If FAIL โ nothing committed, temp branch deleted
Benefits:
- โ Catch integration issues early
- โ Prevent regressions automatically
- โ Only validated code reaches production
- โ Full release context testing (all patches together)
Cannot be disabled - it's a core safety feature.
๐ง Development Workflow
- Patch-based development: Isolated branches for each database change
- Automatic code generation: half-orm Python classes from schema
- Complete testing: Apply patches with full release context
- Conflict detection: Distributed locks prevent concurrent modifications
๐ฆ Release Management
- Semantic versioning: patch/minor/major increments
- Sequential promotion: stage โ rc โ production workflow
- Release candidates: RC validation before production
- Branch cleanup: Automatic deletion after promotion
๐ Production
- Safe upgrades: Automatic database backups before changes
- Incremental deployment: Apply releases sequentially
- Version tracking: Complete release history
- Cloud-compatible: No superuser privileges required
๐ Installation
Prerequisites
- Python 3.9+ required
- PostgreSQL 12+ recommended
- Git for version control
Install
pip install half-orm-dev
Verify Installation
half_orm dev --help
๐ Quick Start
Initialize New Project
# Create project with database
half_orm dev init myproject --database mydb
cd myproject
Clone Existing Project
# Clone from Git
half_orm dev clone https://github.com/user/project.git
cd project
Basic Development Workflow
# 1. Create a release (integration branch)
half_orm dev release create minor # Creates ho-release/0.1.0
# 2. Create a patch
half_orm dev patch create 1-users
# โ Creates ho-patch/1-users branch
# โ Auto-added to 0.1.0-patches.toml as "candidate"
# 3. Add schema changes
echo "CREATE TABLE users (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
username TEXT NOT NULL
);" > Patches/1-users/01_users.sql
# 4. Apply patch (generates Python code)
half_orm dev patch apply
# โ Restores database from production state
# โ Applies SQL patches
# โ Generates Python classes (mydb/public/user.py)
# 5. Write tests (TDD approach)
cat > tests/public/user/test_user_logic.py << 'EOF'
from mydb.public.user import User
def test_user_creation():
"""Test user creation business logic."""
user = User(username='alice').ho_insert()
assert user['username'] == 'alice'
assert user['id'] is not None
EOF
# 6. Run tests locally
pytest
# 7. Commit your work
git add .
git commit -m "Add users table with tests"
# 8. Merge patch - AUTOMATIC VALIDATION!
git checkout ho-patch/1-users
half_orm dev patch merge
# โ Creates temp validation branch
# โ Runs pytest automatically
# โ If tests pass: merges into ho-release/0.1.0, status โ "staged"
# โ If tests fail: aborts, nothing committed
# 9. Promote to production
half_orm dev release promote rc # Optional: create release candidate
half_orm dev release promote prod # Merge to ho-prod + create tag
๐ป Core Workflow
Branch Strategy
ho-prod (main production branch)
โ
โโโ ho-release/0.17.0 (integration branch, deleted after prod)
โ โโโ ho-patch/6-feature-x (temporary, deleted after merge)
โ โโโ ho-patch/7-bugfix-y (temporary, deleted after merge)
โ โโโ ho-patch/8-auth-z (temporary, deleted after merge)
โ
โโโ ho-release/0.18.0 (next version in parallel)
โโโ ho-patch/10-new-api (temporary, deleted after merge)
Branch Types:
- ho-prod: Stable production branch (source of truth)
- ho-release/X.Y.Z: Integration branches (temporary)
- ho-patch/ID: Patch development branches (temporary)
Release Files
.hop/releases/
โโโ 0.17.0-patches.toml # Development (mutable: candidate/staged status)
โโโ 0.17.0-rc1.txt # Release candidate snapshot (immutable)
โโโ 0.17.0.txt # Production snapshot (immutable)
โโโ 0.18.0-patches.toml # Next version in progress
Patch States:
- candidate: In development (
"patch-id" = "candidate"in TOML) - staged: Integrated, awaiting promotion (
"patch-id" = "staged"in TOML) - released: Deployed to production (in
X.Y.Z.txtsnapshot)
Development Cycle
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ DEVELOPMENT WORKFLOW โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 1. release create <level> Create ho-release/X.Y.Z โ
โ 2. patch create <id> Create patch (auto-candidate) โ
โ 3. patch apply Apply & test changes โ
โ 4. patch merge Merge into release (TESTS!) โ
โ โ
Tests pass โ integrated โ
โ โ Tests fail โ aborted โ
โ โ
โ RELEASE PROMOTION โ
โ 5. release promote rc Create RC (optional) โ
โ 6. release promote prod Merge to ho-prod + deploy โ
โ โ
โ PRODUCTION DEPLOYMENT โ
โ 7. update Check available releases โ
โ 8. upgrade Apply on production servers โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Command Reference
Init & Clone
# Create new project
half_orm dev init <package_name> --database <db_name>
# Clone existing project
half_orm dev clone <git_origin>
Patch Commands
# Create new patch (must be on ho-release/* branch)
half_orm dev patch create <patch_id>
# Apply current patch (must be on ho-patch/* branch)
half_orm dev patch apply
# Merge patch into release (AUTOMATIC VALIDATION!)
# Must be on ho-patch/* branch
half_orm dev patch merge
Tip: Patch IDs must start with a number (e.g., 123-add-users). This number automatically closes the corresponding GitHub/GitLab issue #123 when the patch is merged.
Release Commands
# Create new release
half_orm dev release create patch # X.Y.(Z+1)
half_orm dev release create minor # X.(Y+1).0
half_orm dev release create major # (X+1).0.0
# Promote to release candidate (optional)
half_orm dev release promote rc
# Promote to production
half_orm dev release promote prod
# Hotfix workflow
half_orm dev release hotfix # Reopen production version
half_orm dev release promote hotfix # Deploy hotfix
Production Commands
# Check available releases
half_orm dev update
# Apply releases to production
half_orm dev upgrade [--to-release X.Y.Z]
# Dry run (simulate upgrade)
half_orm dev upgrade --dry-run
Note: Use half_orm dev <command> --help for detailed help on each command.
๐ฏ Example: Team Collaboration
# Integration Manager: Create release
half_orm dev release create minor # Creates ho-release/0.17.0
# Developer A: Work on feature
git checkout ho-release/0.17.0
half_orm dev patch create 456-dashboard
# ... develop and test ...
git checkout ho-patch/456-dashboard
half_orm dev patch merge # Tests run automatically
# โ Status: "staged" in 0.17.0-patches.toml
# Developer B: Sync and create patch
git checkout ho-release/0.17.0
git pull origin ho-release/0.17.0 # Get A's changes
half_orm dev patch create 789-reports
# ... develop and test ...
git merge origin/ho-release/0.17.0 # Sync again
git checkout ho-patch/789-reports
half_orm dev patch merge
# โ Tests run with BOTH 456 + 789 together!
# โ Both validated in full release context
๐ Best Practices
Development
โ DO:
- Write tests FIRST (TDD approach)
- Run
pytestlocally beforepatch merge - Use descriptive patch IDs:
123-add-user-authentication - Keep patches focused (one feature per patch)
- Test patches thoroughly
โ DON'T:
- Skip writing tests (validation will fail anyway)
- Mix multiple features in one patch
- Bypass test validation (it's there for safety)
- Modify files outside your patch directory
Release Management
โ DO:
- Trust the automatic test validation system
- Test RC thoroughly before promoting to production
- Use semantic versioning consistently
- Review test failures carefully before retrying
โ DON'T:
- Skip RC validation
- Force promote without fixing issues
- Bypass test validation
- Ignore test failures
Production Deployment
โ DO:
- Always run
updatefirst to check available releases - Use
--dry-runto preview changes - Verify backups exist before upgrade
- Verify all tests passed in RC before promoting
โ DON'T:
- Deploy without testing in RC first
- Skip backup verification
- Promote to production if RC tests failed
- Apply patches directly without releases
๐ Documentation
- CONTRIBUTING.md - Development setup, testing, contribution guidelines
- docs/ARCHITECTURE.md - Technical architecture and implementation details
- CLAUDE.md - Quick reference for Claude Code CLI
For detailed technical documentation, see docs/ARCHITECTURE.md.
๐ง Troubleshooting
Error: "Must be on ho-release/* branch"
# Create release or switch to release branch
half_orm dev release create minor
# or
git checkout ho-release/0.17.0
Error: "Must be on ho-patch/* branch"
# Solution: Create or switch to patch branch
# First ensure you're on ho-release/*
git checkout ho-release/0.17.0
half_orm dev patch create <patch_id>
# or
git checkout ho-patch/<patch_id>
Error: "Patch not found in candidates file"
# Solution: Patch must be created from ho-release/* branch
# to be automatically added to candidates
git checkout ho-release/0.17.0
half_orm dev patch create <patch_id>
Error: "Repository is not clean"
# Solution: Commit or stash changes
git status
git add .
git commit -m "Your message"
# or
git stash
Error: "Repository not synced with origin"
# This should not happen - commands handle git operations automatically
# If it does occur:
git pull origin ho-prod
Error: "No stage releases found"
# Solution: Prepare a release first
half_orm dev release new patch
Error: "Active RC exists"
# Cannot promote different version while RC exists
# Solution: Promote current RC to production first
half_orm dev release promote prod
# Then promote your stage
half_orm dev release promote rc
Error: "Tests failed for patch integration"
# Fix tests or code, then retry
half_orm dev patch apply # Test locally first
pytest # Verify tests pass
# Fix issues
vim Patches/123-feature/01_schema.sql
vim tests/test_feature.py
# Try again
git checkout ho-patch/123-feature
half_orm dev patch merge # Tests will run again
Error: "Repository is not clean"
# Commit or stash changes
git status
git add .
git commit -m "Your message"
# or
git stash
For more troubleshooting, see docs/ARCHITECTURE.md.
๐ค Contributing
Contributions are welcome! See CONTRIBUTING.md for development setup and guidelines.
Quick start for contributors:
# Clone repository
git clone https://github.com/half-orm/half-orm-dev.git
cd half-orm-dev
# Create virtual environment
python -m venv .venv
source .venv/bin/activate
# Install in development mode
pip install -e .
# Run tests
pytest # All tests
pytest -m "not integration" # Unit tests only
pytest -m integration # Integration tests only
๐ Getting Help
- Issues: GitHub Issues
- Documentation: CONTRIBUTING.md and docs/ARCHITECTURE.md
- half-orm: half-orm Documentation
๐ License
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
Made with โค๏ธ by the half-orm team
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file half_orm_dev-0.17.4a2.tar.gz.
File metadata
- Download URL: half_orm_dev-0.17.4a2.tar.gz
- Upload date:
- Size: 176.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
453e974d42c2f43d48b8b2aa4f8c8c0ed12a1d8efedd0ad07daca331133ddf23
|
|
| MD5 |
36281f48cede83b8b8a679c34046dd5a
|
|
| BLAKE2b-256 |
74b4f325cd96162589ad2e0bebd714cb3c82767c463be8fc3e2fd1ebe2dc60b5
|
File details
Details for the file half_orm_dev-0.17.4a2-py3-none-any.whl.
File metadata
- Download URL: half_orm_dev-0.17.4a2-py3-none-any.whl
- Upload date:
- Size: 193.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c203d44d99d2bd901ca6f4a639ca2b3148e693b04a7ea621f9a3cfc0dd5712e
|
|
| MD5 |
e217d21b092258c81f7e4a05b2ac97fe
|
|
| BLAKE2b-256 |
77346a0f28e955524d07e44c56a2d40a03c69940f172fad247928aeb22f3cfb4
|