Link Migration
A generic tool for schema and data migrations.
The primary inspirations for this library came from Alembic, Django, and Hibernate/Liquibase. The ultimate goal is to allow a lightweight migration framework to be deployed into any technology stack. Much of this currently relies on the user to implement, however with time more and more integrations will be added to the default set.
Version
0.0.12
Installation
If you have pip available on your system, just type::
pip install link-migration
If you’ve already got an old version of link-migration, and want to upgrade, use:
pip install --upgrade link-migration
Usage Introduction
The first thing you’ll need to define is the conf.py file and to specify its location: link_migration -c "path_to_file/conf.py"
Below are the minimum requirements for definitions in conf.py. The important step here is to specify where the migrations folder exists so they can be detected, and to specify where to store and fetch the versions for executed migrations.
import os
import requests
import json
ROOT_DIR = 'link_migration.example_migrations'
MIGRATIONS_ABS_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__)))
MIGRATIONS_DIR = 'link_migration.example_migrations'
def get_current_version():
path = "%s/current_version.txt" % MIGRATIONS_ABS_PATH
with open(path, "r+") as f:
content = f.read()
return int(content)
def set_current_version(version):
path = "%s/current_version.txt" % MIGRATIONS_ABS_PATH
with open(path, "w") as f:
content = f.write(f'{version}')
return int(content)
Link Migration uses the version information to track the migrations schema and to decide the order of execution of the scripts. Link Migration will go through all .py files in your directory and execute all of them version order.
Migrating to a specific version
If you want, you can migrate your database schema to a specific version by informing the --to (or -t) parameter. The attribute version of the migration file will be used as unique identifier:
$ link-migration --to=57
If you don’t specify any version, using --up or --down, Link Migration will migrate the schema to the latest version available in the migrations directories specified in the config file.
Metadata
Release files for link-migration 0.0.21
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| link_migration-0.0.21.tar.gz | 11.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| link_migration-0.0.21-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.6 kB
Release files / link_migration-0.0.21.tar.gz
| Download URL | link_migration-0.0.21.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f445f0b9c59628afa5caa51e061f5ce7f2813113ff101febfd611bff94a80019
|
|
BLAKE2b-256 checksum How to use checksums |
4c1a1ed50867d39b3490f228264910cc56c4a55e4f6abacae8d8828792802445
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Release files / link_migration-0.0.21-py3-none-any.whl
| Download URL | link_migration-0.0.21-py3-none-any.whl |
|---|---|
| Size | 17.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
526c4c07ff84e8d2b8974a14e4f1ecc0f95e69eb4914af01fb1cc0429d6fca3a
|
|
BLAKE2b-256 checksum How to use checksums |
2d55e17b13fc1203abe87047d903aa772ad4ec317857e271f2e0fcc7c83aa20d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Security for link-migration 0.0.21
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.