Skip to main content

A database migration toolkit.

Project description

headlight

A database migration toolkit.

PyPI GitHub Workflow Status GitHub Libraries.io dependency status for latest release PyPI - Downloads GitHub Release Date

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


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)

Uploaded Source

Built Distribution

headlight-0.1.14-py3-none-any.whl (21.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page