No project description provided
Project description
Base Migrator
Liquibase's almost compatible tool that works very similary, but just using only Python code.
Installation
$ pip install basemigrator
Usage
There's basicly two rules to use this tool:
- The changelog file MUST in the same folder as the migrations
- The changelog file MUST follow the expected format specified in the documentation
About the first rule, it's simple, follow this folder structure and you will be fine:
migrations/
├── changelog.xml
├── Table1
│ └── Table1-createtable.sql
└── Table2
└── Table2-createtable.sql
The second rule applies for the changelog file format, which depending on her extension, MUST be one of these two:
XML
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog>
<include file="Table1/Table1-createtable.sql" relativeToChangelogFile="true" />
<include file="Table2/Table2-createtable.sql" relativeToChangelogFile="dev, prod" />
</databaseChangeLog>
YAML
- file: Table1/Table1-createtable.sql
- file: Table2/Table2-createtable.sql
context: dev, prod
The configuration object passed as a parameter for the function that will execute the migrations should have a field named config
that at least
implements the __get__()
method and have the following key-values:
class App:
def __init__(self):
self.config = {
'DB_USER': 'user', # the database user
'DB_PASSWORD': 'password', # the database password
'DB_HOST': 'localhost', # the database host
'DB_DATABASE': 'foo' # the database name
}
To call the migrate()
function, three parameters must be given, they are:
from basemigrator import migrate
migrate(
app=app, # the app configuration object
changelog='/path/to/migrations', # the full path of the migrations folder
context='dev' # the context which the migrations will be applied
)
TODO
- CI/CD
- code linting
- publish package to pypi
- Support different sql clients(postgres, sqlite3, etc)
- Contributing section
- tests/
- change build system, see: https://github.com/tldr-pages/tldr-python-client
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
Hashes for basemigrator-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23af88ea1c6740a5ffb5b2427a3583d7e9db2228c556d9e8da8fb10a39d96d6c |
|
MD5 | a61a4d7748bf6df39c1991a7f9a653b1 |
|
BLAKE2b-256 | fdb98a6b495193a7979e1c4bdb643b634b41a678b94dfb64233d90abd748d7e8 |