half-orm-dev 0.16.0a4__tar.gz → 0.16.0a6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. half_orm_dev-0.16.0a6/PKG-INFO +933 -0
  2. half_orm_dev-0.16.0a6/README.md +893 -0
  3. half_orm_dev-0.16.0a6/half_orm_dev/cli/__init__.py +9 -0
  4. half_orm_dev-0.16.0a6/half_orm_dev/cli/commands/__init__.py +56 -0
  5. half_orm_dev-0.16.0a6/half_orm_dev/cli/commands/apply.py +13 -0
  6. half_orm_dev-0.16.0a6/half_orm_dev/cli/commands/clone.py +102 -0
  7. half_orm_dev-0.16.0a6/half_orm_dev/cli/commands/init.py +323 -0
  8. half_orm_dev-0.16.0a6/half_orm_dev/cli/commands/new.py +15 -0
  9. half_orm_dev-0.16.0a6/half_orm_dev/cli/commands/patch.py +315 -0
  10. half_orm_dev-0.16.0a6/half_orm_dev/cli/commands/prepare.py +21 -0
  11. half_orm_dev-0.16.0a6/half_orm_dev/cli/commands/prepare_release.py +119 -0
  12. half_orm_dev-0.16.0a6/half_orm_dev/cli/commands/promote_to.py +127 -0
  13. half_orm_dev-0.16.0a6/half_orm_dev/cli/commands/release.py +344 -0
  14. half_orm_dev-0.16.0a6/half_orm_dev/cli/commands/restore.py +14 -0
  15. half_orm_dev-0.16.0a6/half_orm_dev/cli/commands/sync.py +13 -0
  16. half_orm_dev-0.16.0a6/half_orm_dev/cli/commands/todo.py +73 -0
  17. half_orm_dev-0.16.0a6/half_orm_dev/cli/commands/undo.py +17 -0
  18. half_orm_dev-0.16.0a6/half_orm_dev/cli/commands/update.py +73 -0
  19. half_orm_dev-0.16.0a6/half_orm_dev/cli/commands/upgrade.py +191 -0
  20. half_orm_dev-0.16.0a6/half_orm_dev/cli/main.py +103 -0
  21. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev/cli_extension.py +5 -5
  22. half_orm_dev-0.16.0a6/half_orm_dev/database.py +901 -0
  23. half_orm_dev-0.16.0a6/half_orm_dev/hgit.py +1025 -0
  24. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev/modules.py +134 -35
  25. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev/patch.py +11 -78
  26. half_orm_dev-0.16.0a6/half_orm_dev/patch_manager.py +1694 -0
  27. half_orm_dev-0.16.0a6/half_orm_dev/patch_validator.py +335 -0
  28. half_orm_dev-0.16.0a6/half_orm_dev/release_manager.py +2841 -0
  29. half_orm_dev-0.16.0a6/half_orm_dev/repo.py +1562 -0
  30. half_orm_dev-0.16.0a6/half_orm_dev/templates/.gitignore +15 -0
  31. half_orm_dev-0.16.0a6/half_orm_dev/templates/conftest_template +42 -0
  32. half_orm_dev-0.16.0a6/half_orm_dev/templates/init_module_template +10 -0
  33. half_orm_dev-0.16.0a6/half_orm_dev/templates/relation_test +23 -0
  34. half_orm_dev-0.16.0a6/half_orm_dev/utils.py +49 -0
  35. half_orm_dev-0.16.0a6/half_orm_dev/version.txt +1 -0
  36. half_orm_dev-0.16.0a6/half_orm_dev.egg-info/PKG-INFO +933 -0
  37. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev.egg-info/SOURCES.txt +25 -4
  38. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev.egg-info/requires.txt +1 -1
  39. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev.egg-info/top_level.txt +1 -0
  40. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/setup.py +33 -5
  41. half_orm_dev-0.16.0a6/tests/__init__.py +0 -0
  42. half_orm_dev-0.16.0a6/tests/conftest.py +329 -0
  43. half_orm_dev-0.16.0a4/PKG-INFO +0 -314
  44. half_orm_dev-0.16.0a4/README.md +0 -278
  45. half_orm_dev-0.16.0a4/half_orm_dev/changelog.py +0 -117
  46. half_orm_dev-0.16.0a4/half_orm_dev/database.py +0 -127
  47. half_orm_dev-0.16.0a4/half_orm_dev/db_conn.py +0 -134
  48. half_orm_dev-0.16.0a4/half_orm_dev/hgit.py +0 -202
  49. half_orm_dev-0.16.0a4/half_orm_dev/repo.py +0 -317
  50. half_orm_dev-0.16.0a4/half_orm_dev/templates/.gitignore +0 -14
  51. half_orm_dev-0.16.0a4/half_orm_dev/templates/base_test +0 -26
  52. half_orm_dev-0.16.0a4/half_orm_dev/templates/init_module_template +0 -6
  53. half_orm_dev-0.16.0a4/half_orm_dev/templates/relation_test +0 -19
  54. half_orm_dev-0.16.0a4/half_orm_dev/utils.py +0 -12
  55. half_orm_dev-0.16.0a4/half_orm_dev/version.txt +0 -1
  56. half_orm_dev-0.16.0a4/half_orm_dev.egg-info/PKG-INFO +0 -314
  57. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/AUTHORS +0 -0
  58. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/LICENSE +0 -0
  59. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev/__init__.py +0 -0
  60. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev/hop.py +0 -0
  61. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev/manifest.py +0 -0
  62. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev/patches/0/1/0/00_half_orm_meta.database.sql +0 -0
  63. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev/patches/0/1/0/01_alter_half_orm_meta.hop_release.sql +0 -0
  64. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev/patches/0/1/0/02_half_orm_meta.view.hop_penultimate_release.sql +0 -0
  65. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev/patches/log +0 -0
  66. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev/patches/sql/half_orm_meta.sql +0 -0
  67. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev/templates/MANIFEST.in +0 -0
  68. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev/templates/Pipfile +0 -0
  69. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev/templates/README +0 -0
  70. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev/templates/module_template_1 +0 -0
  71. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev/templates/module_template_2 +0 -0
  72. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev/templates/module_template_3 +0 -0
  73. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev/templates/setup.py +0 -0
  74. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev/templates/sql_adapter +0 -0
  75. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev/templates/warning +0 -0
  76. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/half_orm_dev.egg-info/dependency_links.txt +0 -0
  77. {half_orm_dev-0.16.0a4 → half_orm_dev-0.16.0a6}/setup.cfg +0 -0
@@ -0,0 +1,933 @@
1
+ Metadata-Version: 2.4
2
+ Name: half_orm_dev
3
+ Version: 0.16.0a6
4
+ Summary: half_orm development Framework.
5
+ Home-page: https://github.com/collorg/halfORM_dev
6
+ Author: Joël Maïzi
7
+ Author-email: joel.maizi@collorg.org
8
+ License: GNU General Public License v3 (GPLv3)
9
+ Keywords: postgres,relation-object mapping
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Topic :: Software Development :: Build Tools
13
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ License-File: AUTHORS
24
+ Requires-Dist: GitPython
25
+ Requires-Dist: click
26
+ Requires-Dist: pydash
27
+ Requires-Dist: half_orm<0.17.0,>=0.16.0
28
+ Requires-Dist: pytest
29
+ Dynamic: author
30
+ Dynamic: author-email
31
+ Dynamic: classifier
32
+ Dynamic: description
33
+ Dynamic: description-content-type
34
+ Dynamic: home-page
35
+ Dynamic: keywords
36
+ Dynamic: license
37
+ Dynamic: license-file
38
+ Dynamic: requires-dist
39
+ Dynamic: summary
40
+
41
+ # half_orm_dev
42
+
43
+ ## **WARNING!** half_orm_dev is still in alpha development phase!
44
+
45
+ **Git-centric patch management and database versioning for halfORM projects**
46
+
47
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
48
+ [![License: GPLv3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
49
+ [![halfORM](https://img.shields.io/badge/halfORM-compatible-green.svg)](https://github.com/halfORM/halfORM)
50
+
51
+ Modern development workflow for PostgreSQL databases with automatic code generation, semantic versioning, and production-ready deployment system.
52
+
53
+ ---
54
+
55
+ ## ⚠️ Breaking Changes (v0.16.0)
56
+
57
+ **This version introduces major architectural changes that completely transform how you use half_orm_dev.**
58
+
59
+ ### What Changed
60
+
61
+ **1. Complete Command Reorganization**
62
+ - **OLD**: `half_orm patch new`, `half_orm patch apply`, `half_orm release new`
63
+ - **NEW**: `half_orm dev patch new`, `half_orm dev patch apply`, `half_orm dev release new`
64
+ - All commands now under `half_orm dev` namespace for better organization
65
+
66
+ **2. New Branch Strategy**
67
+ - **OLD**: Various branch naming conventions
68
+ - **NEW**: Strict `ho-prod`, `ho-patch/*`, `ho-release/*` hierarchy
69
+ - Previous branch structures are not compatible
70
+
71
+ **3. Unified Promotion Command**
72
+ - **OLD**: `half_orm release promote-to-rc`, `half_orm release promote-to-prod`
73
+ - **NEW**: `half_orm dev release promote rc`, `half_orm dev release promote prod`
74
+ - Single `promote` command with explicit target argument
75
+
76
+ **4. Different Release File Organization**
77
+ - **OLD**: CHANGELOG.py-based versioning
78
+ - **NEW**: `releases/*.txt` files with explicit patch lists
79
+ - **Structure**: `X.Y.Z-stage.txt` → `X.Y.Z-rc1.txt` → `X.Y.Z.txt`
80
+
81
+ **5. Test Organization and Validation**
82
+ - **NEW**: Systematic test validation before ANY integration
83
+ - **NEW**: Temporary validation branches (`temp-valid-X.Y.Z`) for safe testing
84
+ - Tests must pass before patches are added to releases
85
+
86
+ ### What Stayed the Same
87
+
88
+ ✅ **Business Logic Code**: Your database schemas, models, and application code remain unchanged
89
+ ✅ **Database Structure**: PostgreSQL schemas and data are not affected
90
+ ✅ **halfORM Integration**: Code generation and ORM features work identically
91
+ ✅ **Semantic Versioning**: MAJOR.MINOR.PATCH logic is preserved
92
+ ✅ **SQL Patch Files**: Format and execution order unchanged
93
+
94
+ ### Migration Guide
95
+
96
+ **If migrating from previous versions:**
97
+
98
+ 1. **Backup your repository** before upgrading
99
+ 2. **Update all scripts** to use `half_orm dev` prefix
100
+ 3. **Reorganize branches** to match new `ho-prod`/`ho-patch/*` structure
101
+ 4. **Convert release files** from CHANGELOG.py to releases/*.txt format
102
+ 5. **Update CI/CD pipelines** with new command syntax
103
+
104
+ **For new projects:** Just follow the Quick Start guide below!
105
+
106
+ ---
107
+
108
+ ## 📖 Description
109
+
110
+ `half_orm_dev` provides a complete development lifecycle for database-driven applications:
111
+ - **Git-centric workflow**: Patches stored in Git branches and release files
112
+ - **Semantic versioning**: Automatic version calculation (patch/minor/major)
113
+ - **Code generation**: Python classes auto-generated from schema changes
114
+ - **Safe deployments**: Automatic backups, rollback support, validation
115
+ - **Team collaboration**: Distributed locks, branch notifications, conflict prevention
116
+ - **Test-driven development**: Systematic validation before any integration
117
+
118
+ Perfect for teams managing evolving PostgreSQL schemas with Python applications.
119
+
120
+ ## ✨ Features
121
+
122
+ ### 🔧 Development
123
+ - **Patch-based development**: Isolated branches for each database change
124
+ - **Automatic code generation**: halfORM Python classes created from schema
125
+ - **Complete testing**: Apply patches with full release context
126
+ - **Conflict detection**: Distributed locks prevent concurrent modifications
127
+
128
+ ### 🧪 Test-Driven Development & Validation
129
+
130
+ **Systematic Testing Before Integration**
131
+
132
+ `half_orm_dev` enforces a **test-first approach** that guarantees code quality:
133
+
134
+ **1. Validation on Temporary Branches**
135
+ ```bash
136
+ # When adding a patch to a release, tests run FIRST
137
+ half_orm dev patch add 456-user-auth
138
+
139
+ # What happens behind the scenes:
140
+ # 1. Creates temp-valid-1.3.6 branch
141
+ # 2. Merges ALL release patches + new patch
142
+ # 3. Runs pytest tests/
143
+ # 4. If tests PASS → commits to ho-prod
144
+ # 5. If tests FAIL → rollback, nothing committed
145
+ ```
146
+
147
+ **2. No Integration Without Tests**
148
+ - ❌ **BLOCKED**: Patches cannot be added to releases if tests fail
149
+ - ✅ **SAFE**: Only validated code reaches stage/rc/production
150
+ - 🔒 **GUARANTEED**: Every release is testable before deployment
151
+
152
+ **3. Business Logic Testing (TDD Best Practice)**
153
+ ```python
154
+ # Your business logic is fully testable
155
+ # Example: tests/test_user_authentication.py
156
+
157
+ def test_user_creation():
158
+ """Test user creation through halfORM models."""
159
+ user = User(
160
+ username='john',
161
+ email='john@example.com'
162
+ ).insert()
163
+
164
+ assert user.id is not None
165
+ assert user.username == 'john'
166
+
167
+ def test_invalid_email_rejected():
168
+ """Test validation prevents invalid emails."""
169
+ with pytest.raises(ValidationError):
170
+ User(username='john', email='invalid').insert()
171
+ ```
172
+
173
+ **4. Full Release Context Testing**
174
+ ```bash
175
+ # Test your patch with ALL previous patches
176
+ half_orm dev patch apply
177
+
178
+ # What happens:
179
+ # 1. Restores DB to production state
180
+ # 2. Applies all RC patches (if any)
181
+ # 3. Applies all stage patches
182
+ # 4. Applies YOUR patch in correct order
183
+ # 5. Generates code
184
+ # → Your tests run in realistic production-like environment
185
+ ```
186
+
187
+ **5. Workflow Integration**
188
+ ```
189
+ ┌───────────────────────────────────────────────────────┐
190
+ │ Development Cycle with Test Validation │
191
+ ├───────────────────────────────────────────────────────┤
192
+ │ 1. Create patch │
193
+ │ 2. Write tests FIRST (TDD) │
194
+ │ 3. Implement feature │
195
+ │ 4. Run tests locally: pytest │
196
+ │ 5. Add to release → AUTOMATIC VALIDATION │
197
+ │ ├─ temp-valid branch created │
198
+ │ ├─ All patches merged │
199
+ │ ├─ pytest runs automatically │
200
+ │ └─ Only commits if tests PASS │
201
+ │ 6. Promote to RC → Tests validated again │
202
+ │ 7. Deploy to prod → Tested code only │
203
+ └───────────────────────────────────────────────────────┘
204
+ ```
205
+
206
+ **Benefits:**
207
+ - ✅ **Catch Integration Issues Early**: Test interactions between patches
208
+ - ✅ **Prevent Regressions**: Existing tests protect against breaking changes
209
+ - ✅ **Document Behavior**: Tests serve as executable specifications
210
+ - ✅ **Safe Refactoring**: Change implementation with confidence
211
+ - ✅ **Team Collaboration**: Clear expectations for code quality
212
+
213
+ ### 📦 Release Management
214
+ - **Semantic versioning**: patch/minor/major increments
215
+ - **Release candidates**: RC validation before production
216
+ - **Sequential promotion**: stage → rc → production workflow
217
+ - **Branch cleanup**: Automatic deletion after RC promotion
218
+ - **Test validation**: Automated testing at every promotion step
219
+
220
+ ### 🚀 Production
221
+ - **Safe upgrades**: Automatic database backups before changes
222
+ - **Incremental deployment**: Apply releases sequentially
223
+ - **Dry-run mode**: Preview changes before applying
224
+ - **Version tracking**: Complete release history in database
225
+ - **Rollback support**: Automatic rollback on failures
226
+
227
+ ### 👥 Team Collaboration
228
+ - **Distributed locks**: Prevent concurrent ho-prod modifications
229
+ - **Branch notifications**: Alert developers when rebase needed
230
+ - **Multiple stages**: Parallel development of different releases
231
+ - **Git-based coordination**: No external tools required
232
+
233
+ ## 🚀 Installation
234
+
235
+ ### Prerequisites
236
+
237
+ - Python 3.8+
238
+ - PostgreSQL 12+
239
+ - Git
240
+ - halfORM (`pip install halfORM`)
241
+
242
+ ### Install
243
+
244
+ ```bash
245
+ pip install half_orm_dev
246
+ ```
247
+
248
+ ### Verify Installation
249
+
250
+ ```bash
251
+ half_orm dev --help
252
+ ```
253
+
254
+ ## 📖 Quick Start
255
+
256
+ ### Initialize New Project
257
+
258
+ ```bash
259
+ # Create project with database
260
+ half_orm dev init myproject --database mydb
261
+
262
+ # Navigate to project
263
+ cd myproject
264
+ ```
265
+
266
+ ### Clone Existing Project
267
+
268
+ ```bash
269
+ # Clone from Git
270
+ half_orm dev clone https://github.com/user/project.git
271
+
272
+ # Navigate to project
273
+ cd project
274
+ ```
275
+
276
+ ### First Patch (Exploratory Development with TDD)
277
+
278
+ ```bash
279
+ # Create patch FIRST (exploratory work)
280
+ half_orm dev patch new 001-users
281
+
282
+ # Write tests FIRST (TDD approach)
283
+ cat > tests/test_users.py << 'EOF'
284
+ def test_user_creation():
285
+ """Test user creation."""
286
+ user = User(username='alice').insert()
287
+ assert user.id is not None
288
+ assert user.username == 'alice'
289
+ EOF
290
+
291
+ # Add schema changes
292
+ echo "CREATE TABLE users (id SERIAL PRIMARY KEY, username TEXT);" > Patches/001-users/01_users.sql
293
+
294
+ # Apply and generate code
295
+ half_orm dev patch apply
296
+
297
+ # Run tests
298
+ pytest
299
+
300
+ # Commit your work
301
+ git add .
302
+ git commit -m "Add users table with tests"
303
+
304
+ # THEN prepare release when ready
305
+ git checkout ho-prod
306
+ half_orm dev release new minor
307
+
308
+ # Add to release (automatic validation runs here!)
309
+ half_orm dev patch add 001-users
310
+ ```
311
+
312
+ ## 💻 Development Workflow
313
+
314
+ ### Complete Cycle: Patch → Release → Deploy
315
+
316
+ ```
317
+ ┌─────────────────────────────────────────────────────────────────┐
318
+ │ DEVELOPMENT (ho-prod branch) │
319
+ ├─────────────────────────────────────────────────────────────────┤
320
+ │ 1. patch new <id> Create patch branch │
321
+ │ 2. patch apply Apply & test changes │
322
+ │ │
323
+ │ RELEASE PREPARATION │
324
+ │ 3. release new <level> Prepare release container │
325
+ │ 4. patch add <id> Add to release (TESTS RUN HERE!) │
326
+ │ 5. release promote rc Create release candidate │
327
+ │ │
328
+ │ PRODUCTION DEPLOYMENT │
329
+ │ 6. release promote prod Deploy to production │
330
+ │ 7. update Check available releases │
331
+ │ 8. upgrade Apply on production servers │
332
+ └─────────────────────────────────────────────────────────────────┘
333
+ ```
334
+
335
+ ### Workflow Details
336
+
337
+ #### Step 1: Create Patches (Exploratory Development)
338
+
339
+ ```bash
340
+ # Create patch branch and directory
341
+ half_orm dev patch new 123-feature-name
342
+
343
+ # Now on ho-patch/123-feature-name branch
344
+ # Add SQL/Python files to Patches/123-feature-name/
345
+ ```
346
+
347
+ #### Step 2: Develop and Test (TDD Approach)
348
+
349
+ ```bash
350
+ # FIRST: Write tests
351
+ cat > tests/test_feature.py << 'EOF'
352
+ def test_feature():
353
+ # Your test here
354
+ assert True
355
+ EOF
356
+
357
+ # THEN: Apply patch (on ho-patch/* branch)
358
+ half_orm dev patch apply
359
+ # → Restores database from production state
360
+ # → Applies all release patches + current patch
361
+ # → Generates Python code
362
+ # → Ready for testing
363
+
364
+ # Run tests
365
+ pytest
366
+
367
+ # Commit your work
368
+ git add .
369
+ git commit -m "Implement feature with tests"
370
+ ```
371
+
372
+ #### Step 3: Prepare Release Container (When Ready)
373
+
374
+ ```bash
375
+ # When ready to integrate: Create the release file that will contain patches
376
+ half_orm dev release new patch # Bug fixes (1.3.5 → 1.3.6)
377
+ half_orm dev release new minor # New features (1.3.5 → 1.4.0)
378
+ half_orm dev release new major # Breaking changes (1.3.5 → 2.0.0)
379
+
380
+ # This creates releases/X.Y.Z-stage.txt (empty, ready for patches)
381
+ ```
382
+
383
+ #### Step 4: Add to Release (⚠️ AUTOMATIC VALIDATION HAPPENS HERE)
384
+
385
+ ```bash
386
+ # Switch to ho-prod
387
+ git checkout ho-prod
388
+
389
+ # Add patch to prepared release
390
+ half_orm dev patch add 123-feature-name
391
+
392
+ # What happens automatically:
393
+ # 1. Creates temp-valid-1.3.6 branch
394
+ # 2. Merges ALL release patches
395
+ # 3. Merges YOUR patch
396
+ # 4. Runs pytest tests/
397
+ # 5. If PASS → commits to ho-prod, archives branch
398
+ # 6. If FAIL → cleanup, nothing committed, error reported
399
+
400
+ # Result:
401
+ # ✓ Patch validated with full integration
402
+ # ✓ Branch archived to ho-release/X.Y.Z/123-feature-name
403
+ # ✓ Only TESTED code in releases/X.Y.Z-stage.txt
404
+ ```
405
+
406
+ #### Step 5: Promote to RC
407
+
408
+ ```bash
409
+ # Create release candidate
410
+ half_orm dev release promote rc
411
+
412
+ # → Renames X.Y.Z-stage.txt → X.Y.Z-rc1.txt
413
+ # → Merges all patch code into ho-prod
414
+ # → Deletes patch branches (cleanup)
415
+ # → Notifies active branches to rebase
416
+ # → Automatically pushes to origin
417
+ ```
418
+
419
+ #### Step 6: Deploy to Production
420
+
421
+ ```bash
422
+ # After RC validation
423
+ half_orm dev release promote prod
424
+
425
+ # → Renames X.Y.Z-rc1.txt → X.Y.Z.txt
426
+ # → Generates schema-X.Y.Z.sql and metadata-X.Y.Z.sql
427
+ # → Updates schema.sql symlink
428
+ # → Commits and pushes to ho-prod automatically
429
+ ```
430
+
431
+ #### Step 7/8: Production Upgrade
432
+
433
+ ```bash
434
+ # On production server (automatically pulls from origin)
435
+ # Check available releases
436
+ half_orm dev update
437
+
438
+ # Apply upgrade (with automatic backup and git pull)
439
+ half_orm dev upgrade
440
+ ```
441
+
442
+ ## 📖 Command Reference
443
+
444
+ ### Init & Clone
445
+
446
+ ```bash
447
+ # Create new project
448
+ half_orm dev init <package_name> --database <db_name>
449
+
450
+ # Clone existing project (automatically pulls from origin)
451
+ half_orm dev clone <git_origin>
452
+ ```
453
+
454
+ ### Patch Commands
455
+
456
+ ```bash
457
+ # Create new patch
458
+ half_orm dev patch new <patch_id> [-d "description"]
459
+
460
+ # Apply current patch (from ho-patch/* branch)
461
+ half_orm dev patch apply
462
+
463
+ # Add patch to stage release (AUTOMATIC VALIDATION!)
464
+ half_orm dev patch add <patch_id> [--to-version X.Y.Z]
465
+ ```
466
+
467
+ ### Release Commands
468
+
469
+ ```bash
470
+ # Prepare next release (patch/minor/major)
471
+ half_orm dev release new patch
472
+ half_orm dev release new minor
473
+ half_orm dev release new major
474
+
475
+ # Promote stage to RC (automatically pushes)
476
+ half_orm dev release promote rc
477
+
478
+ # Promote RC to production (automatically pushes)
479
+ half_orm dev release promote prod
480
+ ```
481
+
482
+ ### Production Commands
483
+
484
+ ```bash
485
+ # Fetch available releases (automatically pulls from origin)
486
+ half_orm dev update
487
+
488
+ # Apply releases to production (automatically pulls from origin)
489
+ half_orm dev upgrade [--to-release X.Y.Z]
490
+
491
+ # Dry run (simulate upgrade)
492
+ half_orm dev upgrade --dry-run
493
+ ```
494
+
495
+ ## 🎯 Common Patterns
496
+
497
+ ### Pattern 1: Exploratory Development with TDD
498
+
499
+ ```bash
500
+ # Start exploring (no release needed yet)
501
+ half_orm dev patch new 123-add-users
502
+
503
+ # Write tests FIRST
504
+ cat > tests/test_users.py << 'EOF'
505
+ def test_user_creation():
506
+ user = User(username='alice').insert()
507
+ assert user.username == 'alice'
508
+ EOF
509
+
510
+ # Add SQL/Python files
511
+ echo "CREATE TABLE users (id SERIAL PRIMARY KEY, username TEXT);" > Patches/123-add-users/01_users.sql
512
+
513
+ # Apply and test
514
+ half_orm dev patch apply
515
+ pytest # Tests should pass
516
+
517
+ # Commit your exploration
518
+ git add .
519
+ git commit -m "Explore users table design with tests"
520
+
521
+ # When satisfied, prepare release
522
+ git checkout ho-prod
523
+ half_orm dev release new minor
524
+
525
+ # Add to release (tests validated automatically!)
526
+ half_orm dev patch add 123-add-users
527
+ ```
528
+
529
+ ### Pattern 2: Planned Development
530
+
531
+ ```bash
532
+ # Know what you want - prepare release first
533
+ half_orm dev release new minor
534
+
535
+ # Create patch
536
+ half_orm dev patch new 456-user-auth
537
+
538
+ # Develop with tests
539
+ # ... add files, write tests ...
540
+
541
+ # Apply and test locally
542
+ half_orm dev patch apply
543
+ pytest
544
+
545
+ # Add to release (automatic validation!)
546
+ git checkout ho-prod
547
+ half_orm dev patch add 456-user-auth
548
+ ```
549
+
550
+ ### Pattern 3: Team Collaboration
551
+
552
+ ```bash
553
+ # Developer A: Working on feature
554
+ half_orm dev patch new 456-dashboard
555
+ # ... develop and test ...
556
+
557
+ # Developer B: Working on another feature
558
+ half_orm dev patch new 789-reports
559
+ # ... develop and test ...
560
+
561
+ # Integration Manager: Add both to release
562
+ git checkout ho-prod
563
+ half_orm dev patch add 456-dashboard # Validates with tests
564
+ half_orm dev patch add 789-reports # Validates 456 + 789 together!
565
+
566
+ # All patches validated together before RC
567
+ ```
568
+
569
+ ### Pattern 4: Multiple Stages
570
+
571
+ ```bash
572
+ # Parallel development of different versions
573
+ # 1. Prepare multiple stages
574
+ half_orm dev release new minor # Creates 1.4.0-stage
575
+ half_orm dev release new patch # Creates 1.3.6-stage
576
+
577
+ # 2. Add patches to specific versions
578
+ half_orm dev patch add 123-hotfix --to-version="1.3.6"
579
+ half_orm dev patch add 456-feature --to-version="1.4.0"
580
+
581
+ # 3. Sequential promotion (must promote 1.3.6 before 1.4.0)
582
+ half_orm dev release promote rc # Promotes 1.3.6-stage → 1.3.6-rc1
583
+ # ... validate ...
584
+ half_orm dev release promote prod # 1.3.6-rc1 → 1.3.6.txt
585
+ # Now can promote 1.4.0
586
+ ```
587
+
588
+ ### Pattern 5: Incremental RC (Fix Issues)
589
+
590
+ ```bash
591
+ # RC1 has issues discovered in testing
592
+ half_orm dev release promote rc # Creates 1.3.5-rc1
593
+
594
+ # Found bug in testing, create fix patch
595
+ half_orm dev patch new 999-rc1-fix
596
+ half_orm dev patch apply
597
+ # ... fix and test ...
598
+
599
+ # Add to NEW stage (same version)
600
+ git checkout ho-prod
601
+ half_orm dev patch add 999-rc1-fix # Validated automatically
602
+
603
+ # Promote again (creates rc2, automatically pushes)
604
+ half_orm dev release promote rc # Creates 1.3.5-rc2
605
+
606
+ # Repeat until RC passes all validation
607
+ ```
608
+
609
+ ### Pattern 6: Production Deployment
610
+
611
+ ```bash
612
+ # On production server (commands automatically pull from origin)
613
+
614
+ # Check available releases
615
+ half_orm dev update
616
+
617
+ # Simulate upgrade
618
+ half_orm dev upgrade --dry-run
619
+
620
+ # Apply upgrade (creates backup automatically, pulls from origin)
621
+ half_orm dev upgrade
622
+
623
+ # Or apply specific version
624
+ half_orm dev upgrade --to-release 1.4.0
625
+ ```
626
+
627
+ ## 🏗️ Architecture
628
+
629
+ ### Branch Strategy
630
+
631
+ ```
632
+ ho-prod (main)
633
+ ├── ho-patch/123-feature (development, temporary)
634
+ ├── ho-patch/124-bugfix (development, temporary)
635
+ └── ho-release/
636
+ └── 1.3.5/
637
+ ├── 123-feature (archived after RC promotion)
638
+ └── 124-bugfix (archived after RC promotion)
639
+ ```
640
+
641
+ **Branch types:**
642
+ - **ho-prod**: Main production branch (source of truth)
643
+ - **ho-patch/\***: Patch development branches (temporary, deleted after RC)
644
+ - **ho-release/\*/\***: Archived patch branches (history preservation)
645
+
646
+ ### Release Files
647
+
648
+ ```
649
+ releases/
650
+ ├── 1.3.5-stage.txt (development, mutable, not present if production ready)
651
+ ├── 1.3.5-rc1.txt (validation, immutable)
652
+ ├── 1.3.5-rc2.txt (fixes from rc1, immutable)
653
+ ├── 1.3.5.txt (production, immutable)
654
+ └── 1.3.6-stage.txt (next development)
655
+ ```
656
+
657
+ **File lifecycle:**
658
+ ```
659
+ X.Y.Z-stage.txt → X.Y.Z-rc1.txt → X.Y.Z.txt
660
+
661
+ X.Y.Z-rc2.txt (if fixes needed)
662
+ ```
663
+
664
+ ### Patch Directory Structure
665
+
666
+ ```
667
+ Patches/
668
+ └── 123-feature-name/
669
+ ├── README.md (auto-generated description)
670
+ ├── 01_schema.sql (schema changes)
671
+ ├── 02_data.sql (data migrations)
672
+ └── 03_indexes.sql (performance optimizations)
673
+ ```
674
+
675
+ **Execution order:** Lexicographic (01, 02, 03...)
676
+
677
+ ### Semantic Versioning
678
+
679
+ ```
680
+ MAJOR.MINOR.PATCH
681
+ │ │ │
682
+ │ │ └── Bug fixes, minor changes (1.3.5 → 1.3.6)
683
+ │ └──────── New features, backward compatible (1.3.5 → 1.4.0)
684
+ └────────────── Breaking changes (1.3.5 → 2.0.0)
685
+ ```
686
+
687
+ ### Workflow Rules
688
+
689
+ 1. **Sequential releases**: Must promote 1.3.5 before 1.3.6
690
+ 2. **Single active RC**: Only one RC can exist at a time
691
+ 3. **Branch cleanup**: Patch branches deleted when promoted to RC
692
+ 4. **Database restore**: `patch apply` always restores from production state
693
+ 5. **Immutable releases**: RC and production files never modified
694
+ 6. **Automatic Git operations**: Push/pull handled by commands automatically
695
+ 7. **⚠️ SYSTEMATIC TEST VALIDATION**: Tests run before ANY integration to stage
696
+
697
+ ## 🔧 Troubleshooting
698
+
699
+ ### Error: "Must be on ho-prod branch"
700
+
701
+ ```bash
702
+ # Solution: Switch to ho-prod
703
+ git checkout ho-prod
704
+ ```
705
+
706
+ ### Error: "Must be on ho-patch/* branch"
707
+
708
+ ```bash
709
+ # Solution: Create or switch to patch branch
710
+ half_orm dev patch new <patch_id>
711
+ # or
712
+ git checkout ho-patch/<patch_id>
713
+ ```
714
+
715
+ ### Error: "Repository is not clean"
716
+
717
+ ```bash
718
+ # Solution: Commit or stash changes
719
+ git status
720
+ git add .
721
+ git commit -m "Your message"
722
+ # or
723
+ git stash
724
+ ```
725
+
726
+ ### Error: "Repository not synced with origin"
727
+
728
+ ```bash
729
+ # This should not happen - commands handle git operations automatically
730
+ # If it does occur:
731
+ git pull origin ho-prod
732
+ ```
733
+
734
+ ### Error: "No stage releases found"
735
+
736
+ ```bash
737
+ # Solution: Prepare a release first
738
+ half_orm dev release new patch
739
+ ```
740
+
741
+ ### Error: "Active RC exists"
742
+
743
+ ```bash
744
+ # Cannot promote different version while RC exists
745
+ # Solution: Promote current RC to production first
746
+ half_orm dev release promote prod
747
+
748
+ # Then promote your stage
749
+ half_orm dev release promote rc
750
+ ```
751
+
752
+ ### Error: "Tests failed for patch integration"
753
+
754
+ ```bash
755
+ # Tests ran on temp-valid branch and failed
756
+ # Solution: Fix your tests or code
757
+ half_orm dev patch apply # Test locally first
758
+ pytest # Verify tests pass
759
+
760
+ # Fix issues in your patch
761
+ vim Patches/123-feature/01_schema.sql
762
+ vim tests/test_feature.py
763
+
764
+ # Try again
765
+ git checkout ho-prod
766
+ half_orm dev patch add 123-feature # Tests will run again
767
+ ```
768
+
769
+ ### Patch apply failed (SQL error)
770
+
771
+ ```bash
772
+ # Database automatically rolled back
773
+ # Solution: Fix SQL files and re-apply
774
+ vim Patches/123-feature/01_schema.sql
775
+ half_orm dev patch apply
776
+ ```
777
+
778
+ ### Lost after conflicts
779
+
780
+ ```bash
781
+ # View repository state
782
+ git status
783
+ git log --oneline -10
784
+
785
+ # View current branch
786
+ git branch
787
+
788
+ # View remote branches
789
+ git branch -r
790
+
791
+ # Return to safe state
792
+ git checkout ho-prod
793
+ # Commands handle git pull automatically
794
+ ```
795
+
796
+ ## 🎓 Best Practices
797
+
798
+ ### Patch Development
799
+
800
+ ✅ **DO:**
801
+ - **Write tests FIRST** (TDD approach)
802
+ - Start with exploratory patches (no release needed initially)
803
+ - Use descriptive patch IDs: `123-add-user-authentication`
804
+ - Test patches thoroughly before adding to release
805
+ - Keep patches focused (one feature per patch)
806
+ - Commit generated code with meaningful messages
807
+ - Create release when patches are ready to integrate
808
+ - Run `pytest` locally before `patch add`
809
+
810
+ ❌ **DON'T:**
811
+ - Mix multiple features in one patch
812
+ - Skip `patch apply` validation
813
+ - Add untested patches to release
814
+ - Modify files outside your patch directory
815
+ - Worry about git push/pull (commands handle it automatically)
816
+ - Skip writing tests (validation will fail anyway)
817
+
818
+ ### Release Management
819
+
820
+ ✅ **DO:**
821
+ - Prepare releases when patches are ready to integrate
822
+ - Trust the automatic test validation system
823
+ - Test RC thoroughly before promoting to production
824
+ - Use semantic versioning consistently
825
+ - Document breaking changes in commit messages
826
+ - Let commands handle git operations automatically
827
+ - Review test failures carefully before retrying
828
+
829
+ ❌ **DON'T:**
830
+ - Skip RC validation (always test before prod)
831
+ - Promote multiple RCs simultaneously
832
+ - Skip backup creation in production
833
+ - Force promote without fixing issues
834
+ - Manually push/pull (let commands handle it)
835
+ - Bypass test validation (it's there for your safety)
836
+
837
+ ### Production Deployment
838
+
839
+ ✅ **DO:**
840
+ - Always run `update` first to check available releases
841
+ - Use `--dry-run` to preview changes
842
+ - Verify backups exist before upgrade
843
+ - Monitor application after deployment
844
+ - Schedule deployments during low-traffic periods
845
+ - Trust commands to handle git operations
846
+ - Verify all tests passed in RC before promoting
847
+
848
+ ❌ **DON'T:**
849
+ - Deploy without testing in RC first
850
+ - Skip backup verification
851
+ - Deploy during peak usage hours
852
+ - Ignore upgrade warnings
853
+ - Apply patches directly without releases
854
+ - Manually git pull (commands do it automatically)
855
+ - Promote to production if RC tests failed
856
+
857
+ ### Testing Best Practices
858
+
859
+ ✅ **DO:**
860
+ - Write tests for all business logic
861
+ - Test database constraints and validations
862
+ - Use fixtures for common test scenarios
863
+ - Test edge cases and error handling
864
+ - Keep tests fast and isolated
865
+ - Document test intentions clearly
866
+ - Run tests locally before pushing
867
+
868
+ ❌ **DON'T:**
869
+ - Skip tests for "simple" changes
870
+ - Write tests that depend on execution order
871
+ - Ignore test failures
872
+ - Write tests without assertions
873
+ - Test implementation details instead of behavior
874
+
875
+ ## 📚 Documentation
876
+
877
+ - **Quick Reference**: This README
878
+ - **Full Documentation**: `docs/half_orm_dev.md`
879
+ - **Development Methodology**: `docs/METHODOLOGY.md`
880
+ - **Development Log**: `docs/dev_log.md`
881
+ - **API Reference**: `python-docs/`
882
+
883
+ ## 🤝 Contributing
884
+
885
+ Contributions are welcome! Please read our contributing guidelines and submit pull requests to our repository.
886
+
887
+ ### Development Setup
888
+
889
+ ```bash
890
+ # Clone repository
891
+ git clone https://github.com/halfORM/half_orm_dev.git
892
+ cd half_orm_dev
893
+
894
+ # Install in development mode
895
+ pip install -e .
896
+
897
+ # Run tests
898
+ pytest
899
+ ```
900
+
901
+ ## 📞 Getting Help
902
+
903
+ ```bash
904
+ # Command help
905
+ half_orm dev --help
906
+ half_orm dev patch --help
907
+ half_orm dev release --help
908
+
909
+ # Specific command help
910
+ half_orm dev patch new --help
911
+ half_orm dev release promote --help
912
+ half_orm dev update --help
913
+ half_orm dev upgrade --help
914
+ ```
915
+
916
+ ### Support
917
+
918
+ - **Issues**: [GitHub Issues](https://github.com/halfORM/half_orm_dev/issues)
919
+ - **Documentation**: [docs/](docs/)
920
+ - **halfORM**: [halfORM Documentation](https://github.com/halfORM/halfORM)
921
+
922
+ ## 📄 License
923
+
924
+ This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.
925
+
926
+ ---
927
+
928
+ **Version**: 0.16.0
929
+ **halfORM**: Compatible with halfORM 0.16.x
930
+ **Python**: 3.8+
931
+ **PostgreSQL**: Tested with 13+ (might work with earlier versions)
932
+
933
+ Made with ❤️ by the halfORM team