Skip to main content

SQL-migrate

SQL is a fantastic language — one of the most successful programming languages in the world.

We can use SQL to manage the schema of our database and migrate data. We believe this is better than trying to replace SQL with a bespoke DSL for migrations.

Managing the database schema of an app in development, however, can be challenging. We need some assistance to manage the complexity:

  • Generate migration files for upward and reverse migrations.
  • Track migration dependencies: ensure that migrations are run in the correct order.
  • Merge migrations from multiple branches: Ensure that schema changes in two or more different branches do not conflict and are resolved satisfactorily.

Behold SQL-migrate:

  • Create migrations
    • automatic migration names based on either timestamp (default, like Diesel) or sequence number (option, like Django).
    • optional descriptive label added to the migration filenames
    • configurable to use a single folder (like Django) or subfolders (like Diesel)
    • three files per migration:
      • NAME.up.sql (or NAME/up.sql) – the SQL script to do the upward migration
      • NAME.dn.sql (or NAME/dn.sql) – the SQL script to do the downward migration
      • NAME.conf.yaml (or NAME/conf.yaml) – configuration for the migration. For now, this includes:
        • the "name" of the migration
        • any "description" that the author has chosen to include
        • a list of the migration's "base" dependencies (so that an DAG of migrations can be modeled to ensure that migrations are applied correctly.)
        • a list of "up" SQL scripts in this migration (default *up.sql)
        • a list of "dn" SQL scripts in this migration (default *dn.sql)
    • support for COPY from an external file for easily loading / updating data.
    • support from COPY from the results of a query to ease bulk data migration.
  • Apply migrations:
    • Creates a migrations table to track which migrations were applied and when.
    • Ensures that migrations are applied in dependency-order (which is not necessarily the same as filesystem order).
    • Disallows migrating a database if there are unmerged branches – ensure that branch conflicts have been resolved in a merge before continuing.
    • Each migration is run within its own transaction, treating it as a unified changeset. It's all or nothing with a given migration.
  • Merge migrations:
    • When creating a new migration where there are unmerged branches, creates a new migration that has the tip of each branch as a dependency, and prompts the user to review the migrations to ensure that conflicts are resolved.

Metadata

Release files for sql-migrate 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sql-migrate 0.1.0
File Size Uploaded Provenance
sql-migrate-0.1.0.tar.gz 2.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sql-migrate 0.1.0
File Interpreter ABI Platform
sql_migrate-0.1.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 10.8 kB

Release files / sql-migrate-0.1.0.tar.gz

Download URL sql-migrate-0.1.0.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
93827526c8bd9710fe41f06f8460d00aa2670d6b5b4cd571b949124a991ac9ac
BLAKE2b-256 checksum
How to use checksums
1a939ff383fa03560f04acd96b549ccb3b6aedff179e37373c1306608fe33e9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

Release files / sql_migrate-0.1.0-py2.py3-none-any.whl

Download URL sql_migrate-0.1.0-py2.py3-none-any.whl
Size 8.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
6ccd03c2bcd9473bed2cec9c30e1723ab333ff70f5ab9458634d681ad84f8db1
BLAKE2b-256 checksum
How to use checksums
f9e85edf393a65b2b14d93a7f02aa2641d3060a21f567ab47e3c16cfc4c4a332
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

Security for sql-migrate 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page