A modern migration tool for SQLAlchemy.
Project description
Pelican
A modern, minimal migration framework for SQLAlchemy
Pelican is a lightweight tool for managing database schema changes. It focuses on readability, simplicity and clean developer experience.
"""20251002014707 - Create spaceships"""
from pelican import migration, create_table, drop_table
@migration.up
def upgrade():
with create_table('spaceships') as t:
t.string('name', nullable=False)
t.integer('crew_capacity', default=1)
t.timestamps()
@migration.down
def downgrade():
drop_table('spaceships')
Installation
Create and activate a virtual environment and install Pelican:
pip install pelican-migration
Configuration
Pelican reads the database URL from a DATABASE_URL environment variable or a .env file in your project root:
DATABASE_URL=postgresql://user:password@localhost/mydb
Supported databases: SQLite, PostgreSQL.
Usage
Generate a migration
pelican generate create_spaceships
Creates db/migrations/<timestamp>_create_spaceships.py from the default template.
Apply migrations
pelican up # apply all pending migrations
pelican up 123 # apply a specific revision
Roll back
pelican down # roll back the latest applied migration
pelican down 123 # roll back a specific revision
Check status
pelican status
Migration Status
------------------------------
✓ 20251001120000 Create users
✓ 20251002014707 Create spaceships
○ 20251003090000 Add crew manifest
Schema DSL
create_table
from pelican import create_table
with create_table('spaceships') as t:
t.string('name', nullable=False)
t.integer('crew_capacity', default=1)
t.boolean('active', default=True)
t.text('description')
t.references('user') # adds user_id FK → users.id
t.timestamps() # adds created_at and updated_at
t.index(['name'], unique=True)
change_table
from pelican import change_table
with change_table('spaceships') as t:
t.string('designation') # add column
t.rename('name', 'full_name') # rename column
t.drop('description') # drop column
t.remove_index(['full_name']) # drop index
drop_table
from pelican import drop_table
drop_table('spaceships')
Column types
| Method | SQLAlchemy type |
|---|---|
t.integer(name) |
Integer |
t.float(name) |
Float |
t.double(name) |
Double |
t.boolean(name) |
Boolean |
t.string(name, length=255) |
String |
t.text(name) |
Text |
t.datetime(name) |
DateTime |
t.timestamps() |
created_at + updated_at |
t.references(model) |
Integer FK to <model_plural>.id |
All methods accept standard SQLAlchemy column kwargs (nullable, default, index, etc.).
Contributing
- Fork the repository.
- Install the development dependencies:
pip install -e ".[dev]"
- Open a PR with your improvements.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pelican_migration-0.1.1a0.tar.gz.
File metadata
- Download URL: pelican_migration-0.1.1a0.tar.gz
- Upload date:
- Size: 26.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0db95c35fb0cfea468857c8a5fa9c0d18d767f289563e11072527d6c043bfad8
|
|
| MD5 |
3108887f355c02709d071c94130214e7
|
|
| BLAKE2b-256 |
7af2accb6a60ecbbcd58d0c4a05a8706f4071c5e21dc64aeb9fe7d2956bf18e7
|
Provenance
The following attestation bundles were made for pelican_migration-0.1.1a0.tar.gz:
Publisher:
publish.yml on PenguinBoi12/pelican
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pelican_migration-0.1.1a0.tar.gz -
Subject digest:
0db95c35fb0cfea468857c8a5fa9c0d18d767f289563e11072527d6c043bfad8 - Sigstore transparency entry: 1342999146
- Sigstore integration time:
-
Permalink:
PenguinBoi12/pelican@d39d68d7f91d81a0c3931071a462ab9ac9eb30ce -
Branch / Tag:
refs/tags/0.1.1-alpha - Owner: https://github.com/PenguinBoi12
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d39d68d7f91d81a0c3931071a462ab9ac9eb30ce -
Trigger Event:
release
-
Statement type:
File details
Details for the file pelican_migration-0.1.1a0-py3-none-any.whl.
File metadata
- Download URL: pelican_migration-0.1.1a0-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
315358376d4eafb1e0c4048c3dfd2af9d7ac139a468b11aa276b9a3554cde20b
|
|
| MD5 |
03b437c5275da3985257cf2180cb45f1
|
|
| BLAKE2b-256 |
0d3b2202cba1cb33ada40cf7d2c8c60d9867a27938f919002642fb52d033546f
|
Provenance
The following attestation bundles were made for pelican_migration-0.1.1a0-py3-none-any.whl:
Publisher:
publish.yml on PenguinBoi12/pelican
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pelican_migration-0.1.1a0-py3-none-any.whl -
Subject digest:
315358376d4eafb1e0c4048c3dfd2af9d7ac139a468b11aa276b9a3554cde20b - Sigstore transparency entry: 1342999190
- Sigstore integration time:
-
Permalink:
PenguinBoi12/pelican@d39d68d7f91d81a0c3931071a462ab9ac9eb30ce -
Branch / Tag:
refs/tags/0.1.1-alpha - Owner: https://github.com/PenguinBoi12
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d39d68d7f91d81a0c3931071a462ab9ac9eb30ce -
Trigger Event:
release
-
Statement type: