Skip to main content

No project description provided

Project description

Many: A library to migrate anything!

Coverage Badge

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:

  1. Subclass the MigrationEngine class and implement its methods.
  2. Optionally, create a customized migration template by using Mako templates.
  3. Initialize your application using init_app function with your customized MigrationEngine and Template
  4. 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:

  1. python migration_app.py revision create -m "My first migration" to create your first revision in the versions folder.
  2. Modify the generated file in the versions to customize your migration.
  3. python migration_app.py migrate up to upgrade the state to the latest migration.
  4. python migration_app.py migrate down to downgrade the state one level. Use python migration_app.py migrate down --level base to 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

many_migrations-1.1.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

many_migrations-1.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

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

Hashes for many_migrations-1.1.tar.gz
Algorithm Hash digest
SHA256 167ede00bfc69506f8a8beab598bae732a95645e01cd15c45fe5461bcb9db4fb
MD5 cff7c82247079586662847ac560e2cf5
BLAKE2b-256 3abd17157972b1035916b743da09909ed643507ab29cc42fd428c6d3a449c329

See more details on using hashes here.

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

Hashes for many_migrations-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5a03511af0796de3bea9595a1d3813be6798acc4b9a460f0d5bfcbf562b71c80
MD5 33a88ec23ea69399c4d9beb03219b29d
BLAKE2b-256 8b7b42028515c4d71c2ef6a139e8ec7c2e0237e1e8736ef1d725d286ea9b7b15

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page