No project description provided
Project description
Many: A library to migrate anything!
Managing state changes in data stores is an important part of the development process. There are many great migration tool available for SQL-like databases. However, there is lack of support for other data stores. Because of that I created a small library called many which can be used to build your own migration tool for any data store.
Creating your own application
To create your own migration application for your data store:
- Subclass the
MigrationEngineclass and implement its methods. - Optionally, create a customized migration template by using
Makotemplates. - Initialize your application using
init_appfunction with your customizedMigrationEngineandTemplate - Run you application.
How this would look like:
# migration_app.py
from many import MigrationEngine, init_app
class CustomEngine(MigrationEngine):
def init_remote(self):
# Add logic to initialize a place where the state can be maintained (e.g. a table).
def remote_exists(self) -> bool:
# Add logic to check whether the remote state exists.
def update_remote(self, state: str):
# Add logic to update the remote state to the provided state
def get_remote(self) -> str:
# Add logic to get the remote state
def prepare_args(self) -> Tuple[Any]:
# Logic to pass any argument to the actual migration (e.g. a session/connection object).
if __name__ == "__main__":
app = init_app(CustomEngine())
app()
Now, this application can be used as follows:
python migration_app.py revision create -m "My first migration"to create your first revision in theversionsfolder.- Modify the generated file in the
versionsto customize your migration. python migration_app.py migrate upto upgrade the state to the latest migration.python migration_app.py migrate downto downgrade the state one level. Usepython migration_app.py migrate down --level baseto downgrade completely.
Examples
I have added some examples to showcase how to use the library by implementing some migration applications for:
- Elasticsearch:
examples/elasticsearch - Apache Iceberg:
examples/iceberg - PostgreSQL:
examples/postgresql
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file many_migrations-1.1.tar.gz.
File metadata
- Download URL: many_migrations-1.1.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.9 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
167ede00bfc69506f8a8beab598bae732a95645e01cd15c45fe5461bcb9db4fb
|
|
| MD5 |
cff7c82247079586662847ac560e2cf5
|
|
| BLAKE2b-256 |
3abd17157972b1035916b743da09909ed643507ab29cc42fd428c6d3a449c329
|
File details
Details for the file many_migrations-1.1-py3-none-any.whl.
File metadata
- Download URL: many_migrations-1.1-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.9 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a03511af0796de3bea9595a1d3813be6798acc4b9a460f0d5bfcbf562b71c80
|
|
| MD5 |
33a88ec23ea69399c4d9beb03219b29d
|
|
| BLAKE2b-256 |
8b7b42028515c4d71c2ef6a139e8ec7c2e0237e1e8736ef1d725d286ea9b7b15
|