Skip to content

Migrations system: sqlite_utils.Migrations and sqlite-utils migrate command, ported from sqlite-migrate #752

Closed

Description

@simonw

The https://github.com/simonw/sqlite-migrate library is still in beta but it's been proving itself for 3 years now. It's time it became a feature of sqlite-utils.

Activity

  1. simonw commented on Jun 20, 2026

    @simonw
    OwnerAuthor

    My plan is to do a sqlite-migrate release that pins to <4, then publish sqlite-utils 4 with this new feature and straight after to a sqlite-migrate release than pins >=4 and imports stuff from the new home.

  2. simonw commented on Jun 20, 2026

    @simonw
    OwnerAuthor

    Actually since there are sqlite-utils 4.x alphas out there that do NOT have the migrate functionality in I think the correct pin for sqlite-migrate is:

    dependencies = [
        "sqlite-utils!=4.0,<4.0.post0"
    ]
  3. changed the title [-]Merge sqlite-migrate into sqlite-utils[/-] [+]Migrations system: `sqlite_utils.Migrations` and `sqlite-utils migrate` command, ported from `sqlite-migrate`[/+] on Jun 21, 2026
  4. simonw commented on Jun 21, 2026

    @simonw
    OwnerAuthor

    Spotted a design flaw in this command, inherited from sqlite-migrate:

    sqlite-utils migrate creatures.db path/to/migrations.py --stop-before add_weight
    

    That path/to/migrations.py file might actually contain more than one migration set. If they both have a migration called add_weight both will stop there. This is a little confusing.

    I want to maintain backwards compatibility with sqlite-migrate so I think I'll solve that like this:

    sqlite-utils migrate creatures.db path/to/migrations.py --stop-before creatures:add_weight --stop-before sales:drop_index
    

    You can optionally namespace the stop before indicators - migration_set:name_of_migration - and you can pass more than one --stop-before.

    The old form still works - if you don't include a : we match on name and ignore the migration set.

  5. added 3 commits that reference this issue on Jun 21, 2026
    3cc27d6
    ee17bce
    783d33b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions