half-orm-dev 0.16.0a9__py3-none-any.whl

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 (58) hide show
  1. half_orm_dev/__init__.py +1 -0
  2. half_orm_dev/cli/__init__.py +9 -0
  3. half_orm_dev/cli/commands/__init__.py +56 -0
  4. half_orm_dev/cli/commands/apply.py +13 -0
  5. half_orm_dev/cli/commands/clone.py +102 -0
  6. half_orm_dev/cli/commands/init.py +331 -0
  7. half_orm_dev/cli/commands/new.py +15 -0
  8. half_orm_dev/cli/commands/patch.py +317 -0
  9. half_orm_dev/cli/commands/prepare.py +21 -0
  10. half_orm_dev/cli/commands/prepare_release.py +119 -0
  11. half_orm_dev/cli/commands/promote_to.py +127 -0
  12. half_orm_dev/cli/commands/release.py +344 -0
  13. half_orm_dev/cli/commands/restore.py +14 -0
  14. half_orm_dev/cli/commands/sync.py +13 -0
  15. half_orm_dev/cli/commands/todo.py +73 -0
  16. half_orm_dev/cli/commands/undo.py +17 -0
  17. half_orm_dev/cli/commands/update.py +73 -0
  18. half_orm_dev/cli/commands/upgrade.py +191 -0
  19. half_orm_dev/cli/main.py +103 -0
  20. half_orm_dev/cli_extension.py +38 -0
  21. half_orm_dev/database.py +1389 -0
  22. half_orm_dev/hgit.py +1025 -0
  23. half_orm_dev/hop.py +167 -0
  24. half_orm_dev/manifest.py +43 -0
  25. half_orm_dev/modules.py +456 -0
  26. half_orm_dev/patch.py +281 -0
  27. half_orm_dev/patch_manager.py +1694 -0
  28. half_orm_dev/patch_validator.py +335 -0
  29. half_orm_dev/patches/0/1/0/00_half_orm_meta.database.sql +34 -0
  30. half_orm_dev/patches/0/1/0/01_alter_half_orm_meta.hop_release.sql +2 -0
  31. half_orm_dev/patches/0/1/0/02_half_orm_meta.view.hop_penultimate_release.sql +3 -0
  32. half_orm_dev/patches/log +2 -0
  33. half_orm_dev/patches/sql/half_orm_meta.sql +208 -0
  34. half_orm_dev/release_manager.py +2841 -0
  35. half_orm_dev/repo.py +1562 -0
  36. half_orm_dev/templates/.gitignore +15 -0
  37. half_orm_dev/templates/MANIFEST.in +1 -0
  38. half_orm_dev/templates/Pipfile +13 -0
  39. half_orm_dev/templates/README +25 -0
  40. half_orm_dev/templates/conftest_template +42 -0
  41. half_orm_dev/templates/init_module_template +10 -0
  42. half_orm_dev/templates/module_template_1 +12 -0
  43. half_orm_dev/templates/module_template_2 +6 -0
  44. half_orm_dev/templates/module_template_3 +3 -0
  45. half_orm_dev/templates/relation_test +23 -0
  46. half_orm_dev/templates/setup.py +81 -0
  47. half_orm_dev/templates/sql_adapter +9 -0
  48. half_orm_dev/templates/warning +12 -0
  49. half_orm_dev/utils.py +49 -0
  50. half_orm_dev/version.txt +1 -0
  51. half_orm_dev-0.16.0a9.dist-info/METADATA +935 -0
  52. half_orm_dev-0.16.0a9.dist-info/RECORD +58 -0
  53. half_orm_dev-0.16.0a9.dist-info/WHEEL +5 -0
  54. half_orm_dev-0.16.0a9.dist-info/licenses/AUTHORS +3 -0
  55. half_orm_dev-0.16.0a9.dist-info/licenses/LICENSE +14 -0
  56. half_orm_dev-0.16.0a9.dist-info/top_level.txt +2 -0
  57. tests/__init__.py +0 -0
  58. tests/conftest.py +329 -0
@@ -0,0 +1,935 @@
1
+ Metadata-Version: 2.4
2
+ Name: half_orm_dev
3
+ Version: 0.16.0a9
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 merge and tests PASS → adds patch id to 1.3.6-stage.txt and commits to ho-prod
144
+ # 5. If anything FAILS → nothing committed (temp branch is deleted)
145
+ ```
146
+
147
+ **2. No Integration Without Tests**
148
+ - ❌ **BLOCKED**: Patches cannot be added to releases if anything fails
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
+ ).ho_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').ho_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 everything is OK │
201
+ │ 6. Promote to RC → Tests validated again, code merged on ho-prod │
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
280
+ half_orm dev patch new 001-users
281
+
282
+ # Add schema changes
283
+ echo "CREATE TABLE users (id SERIAL PRIMARY KEY, username TEXT);" > Patches/001-users/01_users.sql
284
+
285
+ # Write tests (TDD approach)
286
+ cat > tests/public/users/test_users_creation.py << 'EOF'
287
+ def test_user_creation():
288
+ """Test user creation."""
289
+ user = User(username='alice').ho_insert()
290
+ assert user['id'] is not None
291
+ assert user['username'] == 'alice'
292
+ EOF
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
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
+ # Apply patch (on ho-patch/* branch)
350
+ half_orm dev patch apply
351
+ * → Restores database from production state
352
+ * → Applies all release patches + current patch
353
+ * → Generates Python code
354
+ * → Ready for testing
355
+
356
+ ```bash
357
+ # FIRST: Write tests
358
+ cat > tests/public/users/test_users_feature.py << 'EOF'
359
+ def test_feature():
360
+ # Your test here
361
+ assert True
362
+ EOF
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
+ **NOTE**: use `half_orm dev command --help` for detailed help on each command
445
+
446
+ ### Init & Clone
447
+
448
+ ```bash
449
+ # Create new project
450
+ half_orm dev init <package_name> --database <db_name>
451
+
452
+ # Clone existing project (automatically pulls from origin)
453
+ half_orm dev clone <git_origin>
454
+ ```
455
+
456
+ ### Patch Commands
457
+
458
+ ```bash
459
+ # Create new patch
460
+ half_orm dev patch new <patch_id> [-d "description"]
461
+
462
+ # Apply current patch (from ho-patch/* branch)
463
+ half_orm dev patch apply
464
+
465
+ # Add patch to stage release (AUTOMATIC VALIDATION!)
466
+ half_orm dev patch add <patch_id> [--to-version X.Y.Z]
467
+ ```
468
+
469
+ ### Release Commands
470
+
471
+ ```bash
472
+ # Prepare next release (patch/minor/major)
473
+ half_orm dev release new patch
474
+ half_orm dev release new minor
475
+ half_orm dev release new major
476
+
477
+ # Promote stage to RC (automatically pushes)
478
+ half_orm dev release promote rc
479
+
480
+ # Promote RC to production (automatically pushes)
481
+ half_orm dev release promote prod
482
+ ```
483
+
484
+ ### Production Commands
485
+
486
+ ```bash
487
+ # Fetch available releases (automatically pulls from origin)
488
+ half_orm dev update
489
+
490
+ # Apply releases to production (automatically pulls from origin)
491
+ half_orm dev upgrade [--to-release X.Y.Z]
492
+
493
+ # Dry run (simulate upgrade)
494
+ half_orm dev upgrade --dry-run
495
+ ```
496
+
497
+ ## 🎯 Common Patterns
498
+
499
+ ### Pattern 1: Exploratory Development with TDD
500
+
501
+ ```bash
502
+ # Start exploring (no release needed yet)
503
+ half_orm dev patch new 123-add-users
504
+
505
+ # Add SQL/Python files
506
+ echo "CREATE TABLE users (id SERIAL PRIMARY KEY, username TEXT);" > Patches/123-add-users/01_users.sql
507
+
508
+ # Write tests
509
+ cat > tests/public/test_public_users.py << 'EOF'
510
+ def test_user_creation():
511
+ user = User(username='alice').ho_insert()
512
+ assert user['username'] == 'alice'
513
+ EOF
514
+
515
+ # Apply and test
516
+ half_orm dev patch apply
517
+ pytest # Tests should pass
518
+
519
+ # Commit your exploration
520
+ git add .
521
+ git commit -m "Explore users table design with tests"
522
+
523
+ # When satisfied, prepare release
524
+ git checkout ho-prod
525
+ half_orm dev release new minor
526
+
527
+ # Add to release (tests validated automatically!)
528
+ half_orm dev patch add 123-add-users
529
+ ```
530
+
531
+ ### Pattern 2: Planned Development
532
+
533
+ ```bash
534
+ # Know what you want - prepare release first
535
+ half_orm dev release new minor
536
+
537
+ # Create patch
538
+ half_orm dev patch new 456-user-auth
539
+
540
+ # Develop with tests
541
+ # ... add files, write tests ...
542
+
543
+ # Apply and test locally
544
+ half_orm dev patch apply
545
+ pytest
546
+
547
+ # Add to release (automatic validation!)
548
+ git checkout ho-prod
549
+ half_orm dev patch add 456-user-auth
550
+ ```
551
+
552
+ ### Pattern 3: Team Collaboration
553
+
554
+ ```bash
555
+ # Developer A: Working on feature
556
+ half_orm dev patch new 456-dashboard
557
+ # ... develop and test ...
558
+
559
+ # Developer B: Working on another feature
560
+ half_orm dev patch new 789-reports
561
+ # ... develop and test ...
562
+
563
+ # Integration Manager: Add both to release
564
+ git checkout ho-prod
565
+ half_orm dev patch add 456-dashboard # Validates with tests
566
+ half_orm dev patch add 789-reports # Validates 456 + 789 together!
567
+
568
+ # All patches validated together before RC
569
+ ```
570
+
571
+ ### Pattern 4: Multiple Stages
572
+
573
+ ```bash
574
+ # Parallel development of different versions
575
+ # 1. Prepare multiple stages
576
+ half_orm dev release new minor # Creates 1.4.0-stage
577
+ half_orm dev release new patch # Creates 1.3.6-stage
578
+
579
+ # 2. Add patches to specific versions
580
+ half_orm dev patch add 123-hotfix --to-version="1.3.6"
581
+ half_orm dev patch add 456-feature --to-version="1.4.0"
582
+
583
+ # 3. Sequential promotion (must promote 1.3.6 before 1.4.0)
584
+ half_orm dev release promote rc # Promotes 1.3.6-stage → 1.3.6-rc1
585
+ # ... validate ...
586
+ half_orm dev release promote prod # 1.3.6-rc1 → 1.3.6.txt
587
+ # Now can promote 1.4.0
588
+ ```
589
+
590
+ ### Pattern 5: Incremental RC (Fix Issues)
591
+
592
+ ```bash
593
+ # RC1 has issues discovered in testing
594
+ half_orm dev release promote rc # Creates 1.3.5-rc1
595
+
596
+ # Found bug in testing, create fix patch
597
+ half_orm dev patch new 999-rc1-fix
598
+ half_orm dev patch apply
599
+ # ... fix and test ...
600
+
601
+ # Add to NEW stage (same version)
602
+ git checkout ho-prod
603
+ half_orm dev patch add 999-rc1-fix # Validated automatically
604
+
605
+ # Promote again (creates rc2, automatically pushes)
606
+ half_orm dev release promote rc # Creates 1.3.5-rc2
607
+
608
+ # Repeat until RC passes all validation
609
+ ```
610
+
611
+ ### Pattern 6: Production Deployment
612
+
613
+ ```bash
614
+ # On production server (commands automatically pull from origin)
615
+
616
+ # Check available releases
617
+ half_orm dev update
618
+
619
+ # Simulate upgrade
620
+ half_orm dev upgrade --dry-run
621
+
622
+ # Apply upgrade (creates backup automatically, pulls from origin)
623
+ half_orm dev upgrade
624
+
625
+ # Or apply specific version
626
+ half_orm dev upgrade --to-release 1.4.0
627
+ ```
628
+
629
+ ## 🏗️ Architecture
630
+
631
+ ### Branch Strategy
632
+
633
+ ```
634
+ ho-prod (main)
635
+ ├── ho-patch/123-feature (development, temporary)
636
+ ├── ho-patch/124-bugfix (development, temporary)
637
+ └── ho-release/
638
+ └── 1.3.5/
639
+ ├── 123-feature (archived after RC promotion)
640
+ └── 124-bugfix (archived after RC promotion)
641
+ ```
642
+
643
+ **Branch types:**
644
+ - **ho-prod**: Main production branch (source of truth)
645
+ - **ho-patch/\***: Patch development branches (temporary, deleted after RC)
646
+ - **ho-release/\*/\***: Archived patch branches (history preservation)
647
+
648
+ ### Release Files
649
+
650
+ ```
651
+ releases/
652
+ ├── 1.3.5-stage.txt (development, mutable, not present if production ready)
653
+ ├── 1.3.5-rc1.txt (validation, immutable)
654
+ ├── 1.3.5-rc2.txt (fixes from rc1, immutable)
655
+ ├── 1.3.5.txt (production, immutable)
656
+ └── 1.3.6-stage.txt (next development)
657
+ ```
658
+
659
+ **File lifecycle:**
660
+ ```
661
+ X.Y.Z-stage.txt → X.Y.Z-rc1.txt → X.Y.Z.txt
662
+
663
+ X.Y.Z-rc2.txt (if fixes needed)
664
+ ```
665
+
666
+ ### Patch Directory Structure
667
+
668
+ ```
669
+ Patches/
670
+ └── 123-feature-name/
671
+ ├── README.md (auto-generated description)
672
+ ├── 01_schema.sql (schema changes)
673
+ ├── 02_data.sql (data migrations)
674
+ └── 03_indexes.sql (performance optimizations)
675
+ ```
676
+
677
+ **Execution order:** Lexicographic (01, 02, 03...)
678
+
679
+ ### Semantic Versioning
680
+
681
+ ```
682
+ MAJOR.MINOR.PATCH
683
+ │ │ │
684
+ │ │ └── Bug fixes, minor changes (1.3.5 → 1.3.6)
685
+ │ └──────── New features, backward compatible (1.3.5 → 1.4.0)
686
+ └────────────── Breaking changes (1.3.5 → 2.0.0)
687
+ ```
688
+
689
+ ### Workflow Rules
690
+
691
+ 1. **Sequential releases**: Must promote 1.3.5 before 1.3.6
692
+ 2. **Single active RC**: Only one RC can exist at a time
693
+ 3. **Branch cleanup**: Patch branches deleted when promoted to RC
694
+ 4. **Database restore**: `patch apply` always restores from production state
695
+ 5. **Immutable releases**: RC and production files never modified
696
+ 6. **Automatic Git operations**: Push/pull handled by commands automatically
697
+ 7. **⚠️ SYSTEMATIC TEST VALIDATION**: Tests run before ANY integration to stage
698
+
699
+ ## 🔧 Troubleshooting
700
+
701
+ ### Error: "Must be on ho-prod branch"
702
+
703
+ ```bash
704
+ # Solution: Switch to ho-prod
705
+ git checkout ho-prod
706
+ ```
707
+
708
+ ### Error: "Must be on ho-patch/* branch"
709
+
710
+ ```bash
711
+ # Solution: Create or switch to patch branch
712
+ half_orm dev patch new <patch_id>
713
+ # or
714
+ git checkout ho-patch/<patch_id>
715
+ ```
716
+
717
+ ### Error: "Repository is not clean"
718
+
719
+ ```bash
720
+ # Solution: Commit or stash changes
721
+ git status
722
+ git add .
723
+ git commit -m "Your message"
724
+ # or
725
+ git stash
726
+ ```
727
+
728
+ ### Error: "Repository not synced with origin"
729
+
730
+ ```bash
731
+ # This should not happen - commands handle git operations automatically
732
+ # If it does occur:
733
+ git pull origin ho-prod
734
+ ```
735
+
736
+ ### Error: "No stage releases found"
737
+
738
+ ```bash
739
+ # Solution: Prepare a release first
740
+ half_orm dev release new patch
741
+ ```
742
+
743
+ ### Error: "Active RC exists"
744
+
745
+ ```bash
746
+ # Cannot promote different version while RC exists
747
+ # Solution: Promote current RC to production first
748
+ half_orm dev release promote prod
749
+
750
+ # Then promote your stage
751
+ half_orm dev release promote rc
752
+ ```
753
+
754
+ ### Error: "Tests failed for patch integration"
755
+
756
+ ```bash
757
+ # Tests ran on temp-valid branch and failed
758
+ # Solution: Fix your tests or code
759
+ half_orm dev patch apply # Test locally first
760
+ pytest # Verify tests pass
761
+
762
+ # Fix issues in your patch
763
+ vim Patches/123-feature/01_schema.sql
764
+ vim tests/test_feature.py
765
+
766
+ # Try again
767
+ git checkout ho-prod
768
+ half_orm dev patch add 123-feature # Tests will run again
769
+ ```
770
+
771
+ ### Patch apply failed (SQL error)
772
+
773
+ ```bash
774
+ # Database automatically rolled back
775
+ # Solution: Fix SQL files and re-apply
776
+ vim Patches/123-feature/01_schema.sql
777
+ half_orm dev patch apply
778
+ ```
779
+
780
+ ### Lost after conflicts
781
+
782
+ ```bash
783
+ # View repository state
784
+ git status
785
+ git log --oneline -10
786
+
787
+ # View current branch
788
+ git branch
789
+
790
+ # View remote branches
791
+ git branch -r
792
+
793
+ # Return to safe state
794
+ git checkout ho-prod
795
+ # Commands handle git pull automatically
796
+ ```
797
+
798
+ ## 🎓 Best Practices
799
+
800
+ ### Patch Development
801
+
802
+ ✅ **DO:**
803
+ - **Write tests FIRST** (TDD approach)
804
+ - Start with exploratory patches (no release needed initially)
805
+ - Use descriptive patch IDs: `123-add-user-authentication`
806
+ - Test patches thoroughly before adding to release
807
+ - Keep patches focused (one feature per patch)
808
+ - Commit generated code with meaningful messages
809
+ - Create release when patches are ready to integrate
810
+ - Run `pytest` locally before `patch add`
811
+
812
+ ❌ **DON'T:**
813
+ - Mix multiple features in one patch
814
+ - Skip `patch apply` validation
815
+ - Add untested patches to release
816
+ - Modify files outside your patch directory
817
+ - Worry about git push/pull (commands handle it automatically)
818
+ - Skip writing tests (validation will fail anyway)
819
+
820
+ ### Release Management
821
+
822
+ ✅ **DO:**
823
+ - Prepare releases when patches are ready to integrate
824
+ - Trust the automatic test validation system
825
+ - Test RC thoroughly before promoting to production
826
+ - Use semantic versioning consistently
827
+ - Document breaking changes in commit messages
828
+ - Let commands handle git operations automatically
829
+ - Review test failures carefully before retrying
830
+
831
+ ❌ **DON'T:**
832
+ - Skip RC validation (always test before prod)
833
+ - Promote multiple RCs simultaneously
834
+ - Skip backup creation in production
835
+ - Force promote without fixing issues
836
+ - Manually push/pull (let commands handle it)
837
+ - Bypass test validation (it's there for your safety)
838
+
839
+ ### Production Deployment
840
+
841
+ ✅ **DO:**
842
+ - Always run `update` first to check available releases
843
+ - Use `--dry-run` to preview changes
844
+ - Verify backups exist before upgrade
845
+ - Monitor application after deployment
846
+ - Schedule deployments during low-traffic periods
847
+ - Trust commands to handle git operations
848
+ - Verify all tests passed in RC before promoting
849
+
850
+ ❌ **DON'T:**
851
+ - Deploy without testing in RC first
852
+ - Skip backup verification
853
+ - Deploy during peak usage hours
854
+ - Ignore upgrade warnings
855
+ - Apply patches directly without releases
856
+ - Manually git pull (commands do it automatically)
857
+ - Promote to production if RC tests failed
858
+
859
+ ### Testing Best Practices
860
+
861
+ ✅ **DO:**
862
+ - Write tests for all business logic
863
+ - Test database constraints and validations
864
+ - Use fixtures for common test scenarios
865
+ - Test edge cases and error handling
866
+ - Keep tests fast and isolated
867
+ - Document test intentions clearly
868
+ - Run tests locally before pushing
869
+
870
+ ❌ **DON'T:**
871
+ - Skip tests for "simple" changes
872
+ - Write tests that depend on execution order
873
+ - Ignore test failures
874
+ - Write tests without assertions
875
+ - Test implementation details instead of behavior
876
+
877
+ ## 📚 Documentation
878
+
879
+ - **Quick Reference**: This README
880
+ - **Full Documentation**: `docs/half_orm_dev.md`
881
+ - **Development Methodology**: `docs/METHODOLOGY.md`
882
+ - **Development Log**: `docs/dev_log.md`
883
+ - **API Reference**: `python-docs/`
884
+
885
+ ## 🤝 Contributing
886
+
887
+ Contributions are welcome! Please read our contributing guidelines and submit pull requests to our repository.
888
+
889
+ ### Development Setup
890
+
891
+ ```bash
892
+ # Clone repository
893
+ git clone https://github.com/halfORM/half_orm_dev.git
894
+ cd half_orm_dev
895
+
896
+ # Install in development mode
897
+ pip install -e .
898
+
899
+ # Run tests
900
+ pytest
901
+ ```
902
+
903
+ ## 📞 Getting Help
904
+
905
+ ```bash
906
+ # Command help
907
+ half_orm dev --help
908
+ half_orm dev patch --help
909
+ half_orm dev release --help
910
+
911
+ # Specific command help
912
+ half_orm dev patch new --help
913
+ half_orm dev release promote --help
914
+ half_orm dev update --help
915
+ half_orm dev upgrade --help
916
+ ```
917
+
918
+ ### Support
919
+
920
+ - **Issues**: [GitHub Issues](https://github.com/halfORM/half_orm_dev/issues)
921
+ - **Documentation**: [docs/](docs/)
922
+ - **halfORM**: [halfORM Documentation](https://github.com/halfORM/halfORM)
923
+
924
+ ## 📄 License
925
+
926
+ This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.
927
+
928
+ ---
929
+
930
+ **Version**: 0.16.0
931
+ **halfORM**: Compatible with halfORM 0.16.x
932
+ **Python**: 3.8+
933
+ **PostgreSQL**: Tested with 13+ (might work with earlier versions)
934
+
935
+ Made with ❤️ by the halfORM team