Simple DB migration manager for non-bloated projects.
Project description
Not production ready at all. Use at your own risk.
Updb - simple DB migration manager for non-bloated projects
How it works? In short, a single migrations.sql file is used to store recent migrations. There is no need to create tons of up.sql and down.sql.
Only PostgreSQL is supported.
Key points
- Do not create VCS inside of another VCS. There is no need to create tons of up.sql and down.sql files. It doesn't help. You can store all the migrations in a single migrations.sql file.
- Oldest migrations are not needed so you can keep only 10-20 recent migrations in migrations.sql. All migrations are stored in Git any way.
- Using a single file for storing 10-20 recent migrations can help you to observe what is happening to the DB schema. It's easier to read one file instead of 10-20 separated ones. You can read migrations.sql from time to time to gain a better understanding of how your project is going.
- How often do you use a down.sql?
Installation
pip install updb
Usage
- Create updb_conf.py and specify DBNAME and other settings (see example.updb_conf.py).
- Write some migrations in migrations.sql file (just pure SQL, see example1.migrations.sql and example2.migrations.sql). Migrations should be separated by an empty line.
- Run
updbcommand. The script will enumerate new migrations and apply them. - The number of last applied migration will be stored in
public.last_migration_n()function. Additionally it will appeared in migrations.sql at the first line. - Optionally per-table schema will be dumped to schema/{table}.sql files and full DB schema - to schema/schema.sql .
- When you want to create new migrations, just add it to migrations.sql and run
updbagain. - If you need to create an empty DB for tests, use schema/schema.sql . Older versions are available via Git.
Suggested directory structure:
./project/db/migrations.sql
./project/db/schema/{table}.sql
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
updb-0.1.0.tar.gz
(3.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
updb-0.1.0-py3-none-any.whl
(4.5 kB
view details)
File details
Details for the file updb-0.1.0.tar.gz.
File metadata
- Download URL: updb-0.1.0.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.12.3 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05810c5d4e8ad0086643791aab91ad478cf9141f1f1a73bed9c4d459dbd4d43c
|
|
| MD5 |
1246eb6341fd0ae7a7d0ce706332efcc
|
|
| BLAKE2b-256 |
5a93b4f11158650a6b59800319192c6dec287dc368429b92775858fdb4838f08
|
File details
Details for the file updb-0.1.0-py3-none-any.whl.
File metadata
- Download URL: updb-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.12.3 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a72bc53c76d3bdfef9af3b2c6875d1aaf624fe2f5f8cbcf8f708165506642a65
|
|
| MD5 |
748e6991cc48b1f6df8681e1deebb7af
|
|
| BLAKE2b-256 |
97f41d4373d4971837cbcba000636e4d5608c91607a3483ce506871973ce0cfd
|