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 hashes)
Built Distribution
headlight-0.1.14-py3-none-any.whl
(21.0 kB
view hashes)
Close
Hashes for headlight-0.1.14-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54b21baea69bba2fa2f967d9d94fb1957aae847f163c658aadfaa107a76a8751 |
|
MD5 | 216d45e2400ac0305af73c66f18f5220 |
|
BLAKE2b-256 | 7c7b1536c4971415175987bd60c65b1f676f45daed4fb23e7cace96571261480 |