Skip to main content

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

  1. 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.
  2. 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.
  3. 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.
  4. How often do you use a down.sql?

Installation

pip install updb

Usage

  1. Create updb_conf.py and specify DBNAME and other settings (see example.updb_conf.py).
  2. 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.
  3. Run updb command. The script will enumerate new migrations and apply them.
  4. 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.
  5. Optionally per-table schema will be dumped to schema/{table}.sql files and full DB schema - to schema/schema.sql .
  6. When you want to create new migrations, just add it to migrations.sql and run updb again.
  7. 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


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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

updb-0.1.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

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

Hashes for updb-0.1.0.tar.gz
Algorithm Hash digest
SHA256 05810c5d4e8ad0086643791aab91ad478cf9141f1f1a73bed9c4d459dbd4d43c
MD5 1246eb6341fd0ae7a7d0ce706332efcc
BLAKE2b-256 5a93b4f11158650a6b59800319192c6dec287dc368429b92775858fdb4838f08

See more details on using hashes here.

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

Hashes for updb-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a72bc53c76d3bdfef9af3b2c6875d1aaf624fe2f5f8cbcf8f708165506642a65
MD5 748e6991cc48b1f6df8681e1deebb7af
BLAKE2b-256 97f41d4373d4971837cbcba000636e4d5608c91607a3483ce506871973ce0cfd

See more details on using hashes here.

Supported by

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