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.13.tar.gz
(18.4 kB
view hashes)
Built Distribution
headlight-0.1.13-py3-none-any.whl
(21.0 kB
view hashes)
Close
Hashes for headlight-0.1.13-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34ecb099a7f1e51798fe5a2003bc0226b48bfa671678857b0526466966d4f538 |
|
MD5 | 55e3343f63377799de794f928509193d |
|
BLAKE2b-256 | 217a087945c514f443b9d5f069160cb951756e882ed4c3b07bf759e87433ecfe |