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