~olly/yoyo

UUNIQUE constraint failed: _yoyo_migration.migration_hash

Brad Greenlee <bgreenlee@gmail.com>
Details
Message ID
<663F2A8C-6329-444C-9382-B158592A41A4@footle.org>
Sender timestamp
1740662767
DKIM signature
pass
Download raw message
I'm trying to run any unapplied migrations in my app when it starts up. I have this code:

mydir = pathlib.Path(__file__).parent.resolve()
migrations_dir = os.path.join(mydir, "migrations")
migrations_backend = yoyo.get_backend(Config.DATABASE_URI)
migrations = yoyo.read_migrations(migrations_dir)
with migrations_backend.lock():
    migrations_backend.apply_migrations(migrations)

This works on the first run, with a new database, but on subsequent runs I get "sqlite3.IntegrityError: UNIQUE constraint failed: _yoyo_migration.migration_hash". Am I doing something wrong, or is this a bug?

Cheers,

Brad
Reply to thread Export thread (mbox)