A database migration toolkit.
Project description
headlight
A database migration toolkit.
Installation
Install headlight
using PIP or poetry:
pip install headlight
# or
poetry add headlight
Features
- TODO
Usage
Create migration file
# create migration with
headlight new --name initial
It will create a new python file in migrations
directory
Define schema
# migrations/0000_initial.py
from headlight import Blueprint, types
date = "2022-08-21T16:19:13.465195"
author = "alex"
transactional = True
def migrate(schema: Blueprint) -> None:
with schema.create_table('users') as table:
table.autoincrements()
table.add_column('first_name', types.VarCharType(256))
table.add_column('last_name', types.VarCharType(256))
table.add_column('email', types.VarCharType(256))
table.add_column('password', types.VarCharType(512))
table.add_column('active', types.BooleanType(), default='1')
table.add_column('photo', types.VarCharType(512), null=True)
table.add_column('deleted_at', types.DateTimeType(True), null=True)
table.add_created_timestamp('joined_at')
table.add_index(['(lower(email))'], unique=True)
Execute migration
headlight upgrade
All migrations will be applied to the database
Rollback migration
headlight downgrade
The last migration will be rolled back,
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
headlight-0.1.14.tar.gz
(18.4 kB
view details)
Built Distribution
File details
Details for the file headlight-0.1.14.tar.gz
.
File metadata
- Download URL: headlight-0.1.14.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.1 CPython/3.10.7 Linux/5.19.13-arch1-1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84a368d2b44e1f300e6ad809965cdc714ef2fe4856b8d10f30331680a8e60375 |
|
MD5 | 48cac4a58f51e7ebfd5300ed8445aa93 |
|
BLAKE2b-256 | b7b263e1ed9aaae42fa846dfef573e05d0f537d887be595cd84e6f2ce7130d74 |
File details
Details for the file headlight-0.1.14-py3-none-any.whl
.
File metadata
- Download URL: headlight-0.1.14-py3-none-any.whl
- Upload date:
- Size: 21.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.1 CPython/3.10.7 Linux/5.19.13-arch1-1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54b21baea69bba2fa2f967d9d94fb1957aae847f163c658aadfaa107a76a8751 |
|
MD5 | 216d45e2400ac0305af73c66f18f5220 |
|
BLAKE2b-256 | 7c7b1536c4971415175987bd60c65b1f676f45daed4fb23e7cace96571261480 |