No project description provided
Project description
##########################################
__ __ _ _ ___ _
| \/ (_) __ _ _ __ __ _| |_ ___|_ _| |_
| |\/| | |/ _` | '__/ _` | __/ _ \| || __|
| | | | | (_| | | | (_| | || __/| || |_
|_| |_|_|\__, |_| \__,_|\__\___|___|\__|
|___/
##########################################
Handle database migrations with ease managing your database changes with simple SQL files. Make the migration process easier, more manageable and repeteable.
How does this work
Installation
pip install migrateit
Configuration
Configurations can be changed as environment variables.
# basic configuration
MIGRATEIT_DATABASE=postgresql
MIGRATEIT_MIGRATIONS_TABLE=MIGRATEIT_CHANGELOG
MIGRATEIT_MIGRATIONS_DIR=migrateit
# change the database connection variables
VARNAME_DB_URL=DB_URL
VARNAME_DB_HOST=DB_HOST
VARNAME_DB_PORT=DB_PORT
VARNAME_DB_USER=DB_USER
VARNAME_DB_PASS=DB_PASS
VARNAME_DB_NAME=DB_NAME
# database configuration
DB_URL=postgresql://postgres:postgres@localhost:5432/postgres
# -------- or ----------
DB_HOST=localhost
DB_PORT=5432
DB_NAME=postgres
DB_USER=postgres
DB_PASS=postgres
Usage
# initialize MigrateIt to create:
# - database table in the configured database
# - 'migrations' directory inside the MIGRATIONS_DIR
# - 'changelog.json' file inside the MIGRATIONS_DIR
migrateit init
# create a new migration file
migrateit newmigration first_migration
# add your sql commands to the migration file
echo "CREATE TABLE test (id SERIAL PRIMARY KEY, name VARCHAR(50));" > migrateit/migrations/0000_first_migration.sql
# show pending migrations
migrateit showmigrations
# run the migrations
migrateit migrate
# or run a given migration
migrateit migrate 0000
Example
-- Migration 0000_user.sql
-- Created on 2025-05-15T19:55:18.711752
CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY,
email TEXT NOT NULL UNIQUE,
given_name TEXT,
family_name TEXT,
picture TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Rollback migration
DROP TABLE IF EXISTS users;
Help
usage: migrateit newmigration [-h] name
positional arguments:
name Name of the new migration
options:
-h, --help show this help message and exit
usage: migrateit migrate [-h] [--fake] [--update-hash] [--rollback] [name]
positional arguments:
name Name of the migration to run
options:
-h, --help show this help message and exit
--fake Fakes the migration marking it as ran.
--update-hash Update the hash of the migration.
--rollback Undo the given migration and all its applied childs.
usage: migrateit showmigrations [-h] [--validate-sql]
options:
-h, --help show this help message and exit
--validate-sql Validate SQL migration sintax.
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
migrateit-0.4.1.tar.gz
(16.9 kB
view details)
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
migrateit-0.4.1-py3-none-any.whl
(21.6 kB
view details)
File details
Details for the file migrateit-0.4.1.tar.gz.
File metadata
- Download URL: migrateit-0.4.1.tar.gz
- Upload date:
- Size: 16.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d18ecb4099b69f603f70560dbe69b0ebbef908a9a79f107f2381529da3b6f2e
|
|
| MD5 |
ef7dc1fe4becdd6a6e16c3e6ba01a304
|
|
| BLAKE2b-256 |
d4c70c71acb2699693ec275c9a330b7e47c0d9be55850dfad55739680f9250eb
|
File details
Details for the file migrateit-0.4.1-py3-none-any.whl.
File metadata
- Download URL: migrateit-0.4.1-py3-none-any.whl
- Upload date:
- Size: 21.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
389df7cbd68617fe5d0061c8effad7bea01b6543416cdd5ca2135aad5cca3956
|
|
| MD5 |
964b0f24ab510e6e4c8798edea38b168
|
|
| BLAKE2b-256 |
2c1f61aa64a63696e45a38794d7dea7a6871f384239e3930c19d28b5b1518b76
|