hop
is a command-line tool provided with the half_orm
library. It allows you to manage the full lifecycle of your PostgreSQL/Python projects, following a GitOps approach.
The hop
tool distinguishes between two environment modes: development and production. It offers a Git-based workflow for the development and deployment of your half_orm
projects.
To create a new hop
project from an existing PostgreSQL database, use the new
command:
hop new <database_name> [--devel]
The --devel
option is important. It allows adding specific tables and views to the database model, which are necessary for version tracking with hop
.
Once the project is initialized, you can start working on your data model and Python code in a hop
directory.
Version management with hop
is done incrementally by preparing successive "releases":
hop prepare [-l <level>] [-m <message>]
: Prepares a new release (level:patch
,minor
, ormajor
)hop apply
: Applies the changes for the release in preparationhop release [--push]
: Validates and pushes the release in preparation
You can also:
hop undo
: Cancel the changes for the release being prepared
hop prepare -l patch -m "Bug fixes"
- Modify the SQL files in
Patches/<version>/...
- Modify your Python code
hop apply
to apply the changesgit add/commit ...
hop release --push
to validate and push the release
In a production environment, hop
allows you to deploy and manage different versions of your project.
hop upgrade
: Updates the database to the latest published releasehop restore <version>
: Restores the database to a specific release version
Before validating a new release with hop release
, the tool automatically runs the tests defined in your project (using pytest by default). This ensures the integrity of your code and data model at each step.
- Test examples for the
hop
command - [TODO] Complete documentation for the
hop
tool
With hop
, you benefit from a powerful tool to manage the full lifecycle of your half_orm
projects, following modern development best practices such as continuous integration, automated testing, and continuous deployment.