1
This repository has been archived on 2022-08-08. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
alembic-data/README.md
Kim Wittenburg ce50e7f93b Update README.md
2020-07-22 11:15:46 +02:00

1005 B
Raw Permalink Blame History

alembic-data

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.

from alembic_data import *

class Model:
  ...

register_object(Model(...))
register_object(Model(...))

Alternatively you can declare a model as a managed model. A managed models 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.

from alembic_data import *

@managed_model
class Model:
  ...

register_object(Model(...))
register_object(Model(...))
# There will only be 2 instances of Model