From ce50e7f93b83320a3e3c3875317e9aa3593bbb63 Mon Sep 17 00:00:00 2001 From: Kim Wittenburg Date: Wed, 22 Jul 2020 11:15:46 +0200 Subject: [PATCH] Update README.md --- README.md | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 89f7026..943d976 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,36 @@ # alembic-data -Data Migrations for Alembic/SQLAlchemy. \ No newline at end of file +Data Migrations for Alembic/SQLAlchemy. + +## State of this Project + +This project was originally written as part of Karman but then abandoned in the process of migrating to non-relational databases. No further development will be done. + +## Usage + +When declaring models you can register specific object instances to be created during migrations. Currently the detection of changes is very rudimentary. + +```python +from alembic_data import * + +class Model: + ... + +register_object(Model(...)) +register_object(Model(...)) +``` + +Alternatively you can declare a model as a *managed model*. A managed model’s instances will be exclusively created by alembic-data. This is probably the most useful application. This way alembic-data can make sure that only objects created via `register_object` will exist in the database. + +```python +from alembic_data import * + +@managed_model +class Model: + ... + +register_object(Model(...)) +register_object(Model(...)) +# There will only be 2 instances of Model +``` +